Monday, January 25, 2010

PEM from/to P12

I commonly need to convert between PEM and p12

PEM
Is an ASCII format and can be opened with a text editor. It is used by most SSL-based tools. Key and certificate are two separate files.
p12
Acutally: Pkcs12 is used by most browsers. Key and certificate are in one file.

PEM to P12

You need both the key and the certificate:

 
openssl pkcs12 -export -in usercert.pem -inkey userkey.pem -out bundle.p12

P12 to PEM

 
openssl pkcs12 -in bundle.p12 -out userkey.pem -nodes -clcerts

The resulting file contains both the key and certificate. Use a text editor to split into two files again.

3 comments:

  1. Thanks, short and straight to the point.

    ReplyDelete
  2. You can generate P12 to PEM file online here: http://www.logisticinfotech.com/blog/push-notification-p12-to-pem-online/

    They have developed very great document as well.

    ReplyDelete
    Replies
    1. Uploading your private key (even encrypted) and certificate to a public website is a huge security risk and should not be used. I would strongly warn against this method and would use a local openssl executable instead.

      Delete

Home

Followers