Answer
If your certificate is exported with DER encoding
, then use the accepted answer:
openssl x509 -inform der -in certificate.cer -out certificate.pem
If your certificate is exported with Base-64 encoding
, then rename the file's extension from .cer
to .pem
since 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:
A .pem
format certificate file will most likely be ASCII-readable.
It will have a line that starts with:
-----BEGIN CERTIFICATE-----
...followed by Base-64 encoded
data, followed by a
-----END CERTIFICATE-----
at the end. There may be other lines before or after.
For example, a .pem
certificate (shortened):
-----BEGIN CERTIFICATE-----
MIIG6DCCBNCgAwIBAgITMgAAGCeh8HZoCVDcnwAAAAAYJzANBgkqhkiG9w0BAQsF
ADBAMRUwEwYKCZImiZPyLGQBGRYFbG9jYWwxEzARBgoJkiaJk/IsZAEZFgNkb3Ix
EjAQBgNVBAMTCURPUi1TVUJDQTAeFw0yMDA1MDExNTI0MTJaFw0yMjA1MDExNTI0
MTJaMBYxFDASBgNVBAMTC3dwZG9yd2VibDE2MIIBIjANBgkqhkiG9w0BAQEFAAOC
...
-----END CERTIFICATE-----