How to create .pfx file or PKCS12 or .pfx file for my SSL Cert from certificate and private key?

 How to create .pfx file or PKCS12 or .pfx file for my SSL Cert from certificate and private key?

 

You need to use openssl and command:

(from Godaddy example) for P12

openssl pkcs12 -export -in mydomain.crt -inkey mydomain.com.key -certfile gd_bundle-g2-g1.crt -out mydomain.p12

 

For PFX

openssl pkcs12 -export -out domain.name.pfx -inkey domain.name.key -in domain.name.crt


Using Windows there is tool for that

The Microsoft Pvk2Pfx command line utility


Pvk2Pfx (Pvk2Pfx.exe) is a command-line tool copies public key and private key information contained in .spc, .cer, and .pvk files to a Personal Information Exchange (.pfx) file.


http://msdn.microsoft.com/en-us/library/windows/hardware/ff550672(v=vs.85).aspx 

 

Solution for Windows that doesn't require OpenSSL installed

I recently was trying to solve the same issue - and I only had a windows laptop with no openssl installed (and no enough admin rights to install it). Turns out windows has built-in utility called certutil that is capable of combining .crt and .key files into .pfx. Docs are here.

You need to create a new folder and place you .crt and key files in it. Rename both files to have the same name (but different extension):

{{sitename}}.crt
{{siteName}}.key

In case your key file is a regular txt - just change extension to .key.

After that open cmd in that folder and run certutil -mergepfx [INPUTFILE] [OUTPUTFILE]

Example:

certificate file: mySite.crt

key file: mySite.key

certutil command: certutil -mergepfx mySite.crt mySite.pfx

Note: you will be asked to provide password for newly created .pfx file - don't forget to memorise/store it - as it will be required during certificate import on the target system.

 

 

 

Comments

Popular posts from this blog

How to clean DB from old logs in Magento 1.x

Securing the Pi-hole with fail2ban to prevent DNS Amplification attacks

Apache 2.4 + mod_wsgi + Python 3.7 + Django installation on Centos 7.10