Converting a public certificate + key into a .PFX (PKCS12) file

One of those things I have to do infrequently enough that I need to write down the steps.

Scenario: I’ve just received a new certificate in the format of 2 files: the public certificate and the key. I need to convert them into a PFX (PKCS12 file) for use on Windows.

For this example, let’s assume that the public cert file is mahaffy.cer and the key file is mahaffy.key. This also assumes that openssl is installed.

All we need is a one-line openssl command to produce the mahaffy.pfx file:

openssl pkcs12 -export -out mahaffy.pfx -inkey mahaffy.key -in mahaffy.cer

OpenSSL will prompt you for the password for the new PFX file.

Leave a Reply

Your email address will not be published. Required fields are marked *