The certificate of my website just expired, and I bought a new (free) one from AliCloud, downloaded one server.pem file and one server.key file.
Then, I use openssl x509 -outform der -in server.pem -out server.crt to create the server.crt file. Then openssl x509 -noout -text -in server.crt returned me an error:
unable to load certificate
4562605504:error:0909006C:PEM routines:get_name:no start line:crypto/pem/pem_lib.c:745:Expecting: TRUSTED CERTIFICATE
I also tried server.crt in production, it just did not work.
Does anyone know how to properly generate .crt file?
openssl x509like most OpenSSL commandline operations defaults to input format PEM, so if you want to read a DER format file use-inform der. However, I don't know of any web server that is configured with a DER format cert (although some use PKCS12 in DER, which is very different from just a cert). BTW the error message is a bit misleading: the default will actually read either typeCERTIFICATEor typeTRUSTED CERTIFICATEin PEM, and the former is much more common, but the error message states only the latter. – dave_thompson_085 Jun 13 '20 at 00:14