Converting SSL Certificates

Here is a quick reference to convert SSL certificate in different formats

Converting PEM encoded certificate to DER
#openssl x509 -outform der -in certificate.pem -out certificate.der

Converting DER encoded certificate to PEM
#openssl x509 -inform der -in certificate.cer -out certificate.pem

Converting PEM encoded certificates to PKCS7 (P7B)
#openssl crl2pkcs7 -nocrl -certfile certificate.cer -out certificate.p7b -certfile CACert.cer

Converting PKCS #7 (P7B) to PEM encoded certificates
#openssl pkcs7 -print_certs -in certificate.p7b -out certificate.cer

Certificates and Keys
Converting PEM encoded Certificate and private key to PKCS #12 / PFX
#openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt

Converting PKCS #7 (P7B) and private key to PKCS #12 / PFX
#openssl pkcs7 -print_certs -in certificate.p7b -out certificate.cer
openssl pkcs12 -export -in certificate.cer -inkey privateKey.key -out certificate.pfx -certfile CACert.cer

Converting PKCS #12 / PFX to PKCS #7 (P7B) and private key
#openssl pkcs12 -in certificate.pfx -out certificate.cer -nodes

Leave a Reply

Your email address will not be published. Required fields are marked *