Convert a CERT/PEM certificate to a PFX certificate

Certificate

Certificate 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:

  1. Import certificate to the certificate store. In Windows Explorer select "Install Certificate" in context menu. enter image description here Follow the wizard and accept default options "Local User" and "Automatically".

  2. 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.

  3. Export Certificate. In context menu select "Export..." menu: enter image description here

Select "Yes, export the private key": enter image description here

You will see that .PFX option is enabled in this case: enter image description here

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionbendeweyView Question on Stackoverflow
Solution 1 - CertificateFrancisView Answer on Stackoverflow
Solution 2 - CertificateIT Hit WebDAVView Answer on Stackoverflow
Solution 3 - CertificateSiim NelisView Answer on Stackoverflow
Solution 4 - CertificateEBlakeView Answer on Stackoverflow