Error while converting pem encoded certificate to der using openssl

certificateopensslSecurityssl-certificatex509certificate

when I try to convert pem encoded certificate to der format , I am getting the below error.

openssl x509 -in test.cer -inform PEM -out output.crt -outform DER

**unable to load certificate300:error:0906D06C:PEM routines:PEM_read_bio:no start line:.\crypto\pem\pem_lib.c:703:Expecting: TRUSTED CERTIFICATE**

Help would be appreciated !.

Link to download the Test.cer click to download

Best Answer

The example CER you've provided is not in a format OpenSSL will accept.

OpenSSL expects PEM formatted certificates to have a maximum line length of 64 characters so you'll need to add a line break after every 64th character. Additionally, you'll want to add -----BEGIN CERTIFICATE----- as the first line and -----END CERTIFICATE----- as the last line. At this point the OpenSSL CLI will allow you to parse and convert the file to DER.

Be sure those begin/end lines have five dashes to start/end them or else you'll still get errors.