How to create .pfx file from certificate and private key?

jlp picture jlp · Jun 10, 2011 · Viewed 916k times · Source

I need .pfx file to install https on website on IIS.

I have two separate files: certificate (.cer or pem) and private key (.crt) but IIS accepts only .pfx files.

I obviously installed certificate and it is available in certificate manager (mmc) but when I select Certificate Export Wizard I cannot select PFX format (it's greyed out)

Are there any tools to do that or C# examples of doing that programtically?

Answer

jdehlin picture jdehlin · Jun 24, 2013

You will need to use openssl.

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

The key file is just a text file with your private key in it.

If you have a root CA and intermediate certs, then include them as well using multiple -in params

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

You can install openssl from here: openssl