OpenSSL: Extract Private Key
1. Extract the Private Key
openssl pkcs12 -in yourfile.pfx -nocerts -out private.keyYou’ll be prompted for the PFX password.
This exports the private key in encrypted format.
If you want an unencrypted private key (optional):
openssl rsa -in private.key -out private_unencrypted.key2. Extract the Certificate
openssl pkcs12 -in yourfile.pfx -clcerts -nokeys -out certificate.crtThis will extract the client certificate and exclude the private key.
3. (Optional) Extract the CA Chain
openssl pkcs12 -in yourfile.pfx -cacerts -nokeys -chain -out ca_bundle.crt4. Verify the Certificate
bashCopyEditopenssl x509 -in certificate.crt -text -nooutTo verify if the certificate and private key match:
bashCopyEditopenssl x509 -noout -modulus -in certificate.crt | openssl md5
openssl rsa -noout -modulus -in private.key | openssl md5If the MD5 hashes match, your certificate and key match.
REFERENCES
PreviousExport a Let’s Encrypt SSL Certificate with Private Key via MMC ConsoleNextTomcat: Install Let's Encrypt SSL-Windows
Last updated
Was this helpful?