KB Article #181359
How can I Extract Certificate and Private Key Files from a .pfx File
Question
I want to import a certificate for “OCSP/SCVP Response Signing and have a pfx file. But VA requests the key and certificate separately. How can I extract the Certificate and Private Key Files from the .pfx File?
Answer
The following steps describe how to export a certificate and private key from a single .pfx file.
- Take the
file you exported (e.g. certname.pfx) and copy it to a system where OpenSSL
is installed (e.g. VA server).
Note: the *.pfx file is in PKCS#12 format and includes both the certificate and the private key.
- Run the
following command to export the private key:
openssl pkcs12 -in certname.pfx -nocerts -out key.pem -nodes
- Run the
following command to export the certificate:
openssl pkcs12 -in certname.pfx -nokeys -out cert.pem
- Run the
following command to remove the passphrase from the private key:
openssl rsa -in key.pem -out server.key