Extracting the public and private key from a PKCS #12 container using OpenSSL

Extract the private key from mycert.pfx:

openssl pkcs12 -in mycert.pfx -nocerts -out my-private-key.pem

Convert .pfx/.p12 to .pem:

openssl pkcs12 -in mycert.pfx -out mycert.pem

Extract the public key:

openssl x509 -inform pem -in mycert.pem -pubkey -out my-public-key.pem

Leave a Reply

Your email address will not be published. Required fields are marked *