Wednesday, April 16, 2014

SSL Certificates: Creating and Converting a PEM file to a P12 file in Linux

First, we'll create the PEM File:

  1. Open a new file called filename.pem
  2. Import your filename.key (key file)
  3. Import your filename.crt (main cert)
  4. Import your intermediate.crt (intermediate cert)
  5. Import your root.crt (root cert)
  6. Make sure there are no spaces between the various certs
Now, the PEM file is ready to use on any Linux box.


To convert the PEM file to a P12 file which can be used on Windows, use the following command:

openssl pkcs12 -export -inkey filename.key -in filename.pem -out filename.p12

NOTE:  You'll see all over the web where people tell you to use -certfile in the command.  That isn't necessary as long as your PEM file has the full certificate chain in it.

To use the .p12 file on Windows, move it to the Windows box and double click on the file ... that will install all the secondary certs into place.  Then, you'll need to do Start --> Run --> MMC and add the snap-in for certificates for the COMPUTER store.  Under the personal certificates, import the .p12 file.

You should be good from here on out.