Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Created September 2, 2018 04:47
Show Gist options
  • Save miguelmota/52a8834603259687080722a9f4660186 to your computer and use it in GitHub Desktop.
Save miguelmota/52a8834603259687080722a9f4660186 to your computer and use it in GitHub Desktop.
OpenSSL generate self-signed certificate authority (CA) and certificate (CRT)
# Creating a new CA
# 1. create the CA key
#openssl genrsa -out ca-key.pem 1024 -config openssl.cnf
openssl genrsa -des3 -out ca-key.pem 1024 -config openssl.cnf
openssl rsa -in ca-key.pem -out ca-key.pem # rm pass
# 2. create a certificate signing request
openssl req -days 365 -new -key ca-key.pem -out ca.csr -config openssl.cnf
# 3. self-sign the request for the creation of the certificate
openssl x509 -req -in ca.csr -out ca.pem -signkey ca-key.pem
# 4. check the cert
openssl x509 -in ca.pem -text
# Generate cert
# First, create private key
openssl genrsa -des3 -out key.pem 1024 -config openssl.cnf
openssl rsa -in key.pem -out key.pem # rm pass
# Second, create a new certificate signing request with private key
openssl req -new -key key.pem -out key.csr -config openssl.cnf
# Lastly, sign certificate signing request with certificate authority private key and cert
openssl ca -days 365 -in key.csr -cert ca.pem -keyfile ca-key.pem -out cert.pem -config openssl.cnf
# Check contents of certificate
openssl x509 -in cert.pem -text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment