Recently, I use a library at work where I need to pass in the PEM format values of the private key and certificate from a pfx file. In this post, I’m going to show how to find these from a pfx file using openssl.
The PEM format of the private key is a Base64 encoded string enclosed between “—–BEGIN PRIVATE KEY—–” and “—–END PRIVATE KEY—–“. For the certificate, it is enclosed between “—–BEGIN CERTIFICATE—–” and “—–END CERTIFICATE—–“
Firstly, make sure openssl is installed. Then in a terminal, navigate to where the pfx file is and run the following command
openssl pkcs12 -in SomePfxFile.pfx -out ResultCert.pem -nodes
Open the result .pem file in any file editor and you should see the PEM format values of the private key and certificate.