ca.pem
- the root CA certificate
ca.pem
- the CA private key
csr.pem
- certificate signing request
cert.pem
- client certificate
pkey.pem
- client private key
C - Country Name (2 letter code)
ST - State or Province Name (full name)
L - Locality Name (eg, city)
O - Organization Name (eg, company)
OU - Organizational Unit Name (eg, section)
CN - Common Name (eg, fully qualified host name)
$ openssl genrsa -des3 -out key.pem 4096
$ openssl req -new -key key.pem -out csr.pem
$ openssl x509 -in csr.pem -out cert.pem -req -signkey key.pem -days 365
$ openssl genrsa -des3 -out key.pem -pkeyopt 4096
$ openssl req -new -x509 -key key.pem -sha256 -days 365 -out ca.pem
$ openssl genrsa -des3 -out pkey.pem 4096
$ openssl req -new -key pkey.pem -out csr.pem
$ openssl x509 -req -in csr.pem -CA ca.pem -CAkey ca-key.pem \
-CAcreateserial -out cert.pem -days 365
$ openssl pkcs12 -export -clcerts -inkey pkey.key \
-in cert.pem -out cert.p12
$ # Validate a certificate chain with intermediate CA cert
$ openssl verify -CAfile ca.pem -untrusted intermediate.pem cert.pem
$ # Validate a certificate with CA cert
$ openssl verify -CAfile ca.pem cert.pem
$ # Validate a single certificate
$ openssl verify cert.pem
$ # Get certificate issuer
$ openssl x509 -in cert.pem -noout -issuer
$ # Get certificate subject
$ openssl x509 -in cert.pem -noout -subject