Convert PFX certificate container to PEM format certificate and key

If you have a .PFX certificate container you can extract the certificate and key with openssl.

Extract the certificate:

openssl pkcs12 -in filename.pfx -clcerts -nokeys -out cert.pem

Extract the key:

openssl pkcs12 -in filename.pfx -nocerts -out key.pem