OpenSSL encoding errors while converting cer to pem OpenSSL encoding errors while converting cer to pem linux linux

OpenSSL encoding errors while converting cer to pem


To expand on existing answer, like explained by ssl.com, a .cer file can be either in der or pem encoding. If it is in der encoding, you'll need to do conversion like you have done, but if it is already in pem encoding, no conversion is necessary and you get the error you've got if you try - and you can just rename the file.

If you're unsure, it is good to know that .der is a binary format, whereas .pem is ascii one. If you echo the contents of your certificate out, a .pem file would look something like this:

-----BEGIN CERTIFICATE-----MIIEuTCCA6G[snip lots of chars]XmCpajQ==-----END CERTIFICATE-----

And a .der file would look like this:

0▒▒0▒▒▒@*▒H▒▒▒▒▒00▒▒1    0   UUS10UVeriSign, Inc.10U                 VeriSign Trust Network1:08U


I had this problem also. Just rename the CER to PEM was enough :)


no need to convert the file from .cer to .pem you just need to use this command and desired result will be getopenssl x509 -inform pem -in certificate.cer -pubkey -noout > certificate_publickey.pemit all depends on which encoding type used to generate the certificate as mentioned by @eis