Is it possible to convert a .pfx (Personal Information Exchange) file to a .cer (Security Certificate) file? Unless I'm mistaken, isn't a .cer somehow embedded inside a .pfx? I'd like some way to extract it, if possible.
Join Stack Overflow to learn, share knowledge, and build your career.
|
|
|
the simple way I believe is to import it then export it, using the certificate manager in Windows Management Console. |
|||||||||||||||||||||
|
|
PFX files are PKCS#12 Personal Information Exchange Syntax Standard bundles. They can include arbitrary number of private keys with accompanying X.509 certificates and a certificate authority chain (set certificates). If you want to extract client certificates, you can use OpenSSL's PKCS12 tool.
The command above will output certificate(s) in PEM format. The ".crt" file extension is handled by both macOS and Window. You mention ".cer" extension in the question which is conventionally used for the DER encoded files. A binart encoding. Try the ".crt" file first and if it's not accepted, easy to convert from PEM to DER:
|
|||||||||||||||||
|
|
I wanted to add a method which I think was simplest of all.
Essentially it does the same thing as Andrew's answer, but it avoids using Windows Management Console (goes straight to the import/export). |
|||||
|
|
If you're working in PowerShell you can use something like the following, given a pfx file InputBundle.pfx, to produce a DER encoded (binary) certificate file OutputCert.der:
Newline added for clarity, but you can of course have this all on a single line. If you need the certificate in ASCII/Base64 encoded PEM format, you can take extra steps to do so as documented elsewhere, such as here: https://superuser.com/questions/351548/windows-integrated-utility-to-convert-der-to-pem If you need to export to a different format than DER encoded, you can change the
|
|||||||||||||||||
|
|
||||
|
|
protected by thirtydot Feb 15 '12 at 10:59
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?