How to convert a .cer certificate to .pem on Linux/Unix and OS X

While trying to update a certificate on a produciton enviroment I ran into the following issue, Apache only accepts certificates in PEM format, since my client provided me with his new certificate on a .cer file I had to find a way to convert it.

For x509 certificates this can be easily achieved using OpenSSL on Linux/Unix and OS X. First make sure you have OpenSSL (comes by default with OS X), open a terminal and issue the following command:

openssl x509 -inform pem -in certificate.cer -outform der -out certificate.pem

Where certificate.cer is the source certificate file you want to convert and certificate.pem is the name of the converted certificate.

9 thoughts on “How to convert a .cer certificate to .pem on Linux/Unix and OS X

  1. The inform and outform options are reversed. The command should be:
    openssl x509 -inform der -in certificate.cer -outform pem -out certificate.pem

  2. You can definitely see your expertise in the work you write.
    The sector hopes for even more passionate writers like you who are
    not afraid to mention how they believe. All the time follow
    your heart.

Leave a Reply

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