I have a .cer
certificate and I would like to convert it to the .pem
format.
If I remember correctly, I used to be able to convert them by exporting the .cer
in Base64, then renaming the file to .pem
.
How do I convert a .cer
certificate to .pem
?
Convert a DER file (.crt .cer .der) to PEM
Source
convert a .cer file in .pem
open a terminal and run the following command
openssl x509 -inform der -in certificate.cer -outform pem -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.
When openssl is not available on your system you could alternatively convert certificates with the java keytool.
However you have to create a java keystore (JKS) first. The certificates can then be imported and exported in different formats.
Converting from DER to PEM:
This blog post explains how to convert certificate formats in detail
Answer
If your certificate is exported with DER encoding, then use the accepted answer:
If your certificate is exported with Base64 encoding, then rename the extension
.cer
to.pem
. The file is already in.pem
format.How to tell that your
.cer
file is in.pem
format?See this stack-o answer, quoted here:
For example, a
.pem
certificate (shortened):Just changing the file extension worked for me:
mv filename.cer filename.pem