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-----
-----BEGIN CERTIFICATE----- MII...D2H -----END CERTIFICATE-----. From openssl, I get the following error:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1338: error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:tasn_dec.c:390:Type=X509– Martin Pecka Nov 14 '16 at 00:27certificate.certocertificate.pem. – slowhand May 16 '17 at 21:11