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.

VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
Clip to Evernote

8 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

    VA:F [1.9.22_1171]
    Rating: +4 (from 4 votes)
  2. Gratzie, your command helped me a lot !!!
    it worked on aix 5.3 with no errors.

    Eduardo

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  3. 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.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>