To convert a PFX file to a PEM file that contains both the certificate and private key, the following command needs to be used:
# openssl pkcs12 -in filename.pfx -out cert.pem -nodes
We can extract the private key form a PFX to a PEM file with this command: