Convert a CERT/PEM certificate to a PFX certificate
CertificateCertificate Problem Overview
I've seen a couple questions about how to convert a PFX to a cert file, but I need to go the other way.
I have two files:
> bob_cert.cert > > bob_key.pem
I'd like to convert them to a single .pfx file. Is there a tool that does this?
Certificate Solutions
Solution 1 - Certificate
openssl pkcs12 -inkey bob_key.pem -in bob_cert.cert -export -out bob_pfx.pfx
Solution 2 - Certificate
Here is how to do this on Windows without third-party tools:
-
Import certificate to the certificate store. In Windows Explorer select "Install Certificate" in context menu. Follow the wizard and accept default options "Local User" and "Automatically".
-
Find your certificate in certificate store. On Windows 10 run the "Manage User Certificates" MMC. On Windows 2013 the MMC is called "Certificates". On Windows 10 by default your certificate should be under "Personal"->"Certificates" node.
-
Export Certificate. In context menu select "Export..." menu:
Select "Yes, export the private key":
You will see that .PFX option is enabled in this case:
Specify password for private key.
Solution 3 - Certificate
I created .pfx file from .key and .pem files.
Like this openssl pkcs12 -inkey rootCA.key -in rootCA.pem -export -out rootCA.pfx
That's not the direct answer but still maybe it helps out someone else.
Solution 4 - Certificate
If you have a self-signed certificate generated by makecert.exe
on a Windows machine, you will get two files: cert.pvk
and cert.cer
. These can be converted to a pfx using pvk2pfx
pvk2pfx
is found in the same location as makecert
(e.g. C:\Program Files (x86)\Windows Kits\10\bin\x86
or similar)
pvk2pfx -pvk cert.pvk -spc cert.cer -pfx cert.pfx