Converting PKCS#12 (.pfx) to PEM with OpenSSL
Overview
This guide will show you how to convert a PKCS#12 file to PEM format using OpenSSL.
Conversion
Extract private and public key to PEM (no encryption/password):
openssl pkcs12 -in certificate.pfx -out certificate.pem -nodes
Extract public key to PEM:
openssl pkcs12 -in certificate.pfx -clcerts -nokeys -out certificate.pem -nodes
Extract private key to PEM:
openssl pkcs12 -in certificate.pfx -nocerts -out key.pem
Extract private key to PEM (no encryption/password):
openssl pkcs12 -in certificate.pfx -nocerts -out key.pem -nodes
Other useful commands
Remove password from private key (from PEM):
openssl rsa -in key.pem -out key-out.pem
Concatinate public and private key:
cat certificate.pem key.pem > combined.pem