Search code examples
certificatessl-certificatex509certificate

How to convert a .csr to .crt using openssl?


well i have tried the below

openssl x509 -req -in <cert_name>.csr -signkey <key_name>.key -out output.crt    

but seems to throw an error

140735226307408:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:703:Expecting: CERTIFICATE REQUEST    

Any solutions?


Solution

  • The source of the problem is the form of your CSR : While working with X509, your data can be store using 2 forms : DER and PEM.

    By default openssl assumes you are using PEM.

    In your case, you should first convert the CSR in PEM format : openssl req -inform DER -in <cert_name>.csr -out <cert_name>.pem And then openssl x509 -req -in <cert_name>.pem -signkey <key_name>.key -out output.crt