How can I validate that a certificate really is in DER format?

user565869 picture user565869 · Dec 20, 2012 · Viewed 11.1k times · Source

Is there some kind of digital signature to a DER which would be apparent in a hex editor?

I've been given a .cer file with binary content of about 1.3 KB. I'm told that it's in DER format, and my reading suggests that certificates with this extension are pretty much all either DER or base-64-encoded DER with a human-readable header, and this file does not have such a header. However, I've been unable to open it to create a key. Before I invest an excessive amount of time in troubleshooting this file, I'd like to be sure it really is in DER format.

Answer

Bruno picture Bruno · Dec 20, 2012

Try this with OpenSSL:

openssl x509 -text -noout -inform DER -in the_file_name.cer

If you need to convert it, you can use this for example:

openssl x509 -inform DER -in the_file_name.cer -outform PEM -out the_file_name.pem