Convert certificate format with OpenSSL

Convert a PEM file to DER (crt etc)
$ openssl x509 -outform der -in certificate.pem -out certificate.crt
Convert a PKCS#12 file (.pfx .p12) containing a private key and certificates to PEM
$ openssl pkcs12 -in keyStore.pfx -out keyStore.pem -nodes
Convert a PEM certificate file and a private key to PKCS#12 (.pfx .p12)
$ openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt
Create a pkcs12 (.pfx or .p12) from OpenSSL files (.pem , .cer, .crt, …)

Generate a PKCS12 from a certificate file (cer/pem), a certificate chain (generally pem or txt), and your private key, you need to use the following command:

openssl pkcs12 -export  \
   -inkey    your_private_key.key \
   -in       your_certificate.cer \
   -certfile your_chain.pem \
   -out      final_result.pfx

You may also like...

Leave a Reply

Your email address will not be published.