h9dmjg
Last Updated: February 25, 2016
·
1.162K
· apeschel

Converting SSL Certificates to PEM

SSL certificates and key files can come in a variety of forms.

  • Certificates PEM, DER, PKCS7, PKCS12
  • Key Files RSA, PKCS12

RSA and PEM are the most basic formats, being just text files.

You can use the openssl program from the command line to convert between forms.

DER to PEM

openssl x509 -inform DER \
-in cert.crt \
-out cert.pem

PKCS7 to PEM

openssl pkcs7 -print_certs \
-in cert.p7b \
-out cert.pem

PKCS12 to PEM

openssl pkcs12 -clcerts -nokeys \
-in cert.pfx \
-out cert.pem

PKCS12 to RSA Key

openssl pkcs12 -nocerts -nodes \
-in cert.pfx \
-out cert.key