Convert PEM to PFX without OpenSSL
A PFX file, also called PKCS #12 or .p12, holds a certificate and its private key in one password-protected file. It is the format Windows, IIS and many appliances ask for. This guide builds one from PEM files with CertConvert, entirely on your own machine.
What you need
- The certificate as a PEM file, usually
.pemor.crt. - The private key that belongs to it. PKCS #8, PKCS #1 and SEC 1 keys all work, encrypted or not.
- A password to protect the new PFX.
CertConvert reads the format from the file’s content, so a mislabelled extension does not matter.
In the app
- Open the Convert view and drag in the certificate, or choose Add Files….
- Choose Add Key File… and pick the private key. If the key is encrypted, type its passphrase in Key Password.
- Set Target format to PKCS #12 (.pfx).
- Type the password for the new file in PFX Password.
- Choose Convert And Save… and pick where to save it.
CertConvert checks that the key belongs to the certificate before it writes anything. If they do not match, it stops and tells you instead of producing a PFX that will fail later.
To include the intermediate and root certificates in the right order, build the PFX from the Chain view instead. See fix certificate chain order.
From the command line
certconvert convert device.pem --key device.key -o device.pfx --out-password secret
# the key is encrypted
certconvert convert device.pem --key device.key --key-password keypass \
-o device.pfx --out-password secret
# check the result
certconvert inspect device.pfx --password secret
The output format is taken from the .pfx or .p12 extension, or from --to pfx.
The OpenSSL equivalent
For comparison, the same job in OpenSSL is:
openssl pkcs12 -export -in device.pem -inkey device.key -out device.pfx
CertConvert does this without a shell, and it verifies the key match first.
OpenSSL is named here for comparison only. See trademarks.
Common snags
“The private key does not match any certificate being exported”
The key and certificate are not a pair. Open the Keys view, load the key, choose the certificate and use Check Match to find the right one.
An older system rejects the PFX
By default the PFX is encrypted with AES-256 and SHA-256. Some older importers only understand the legacy scheme. Tick Legacy Ciphers (Old Importers), or pass --legacy, to write 3DES and SHA-1 instead.
The PFX has an empty password
CertConvert will write a PFX with no password, but it warns you. Many importers refuse such a file, and the private key inside is unprotected.
.pfx or .p12?
They are the same format. Use whichever extension the destination expects.
Related guides
- Convert PFX to PEM and extract the private key
- Fix certificate chain order
- Everything CertConvert does