I got this weird error while deploying an SSL certificate from GoDaddy

nginx: [emerg] SSL_CTX_use_PrivateKey_file failed (SSL: error:0909006C:PEM routines:get_name:no start line:Expecting: ANY PRIVATE KEY error:140B0009:SSL routines:SSL_CTX_use_PrivateKey_file:PEM lib)

I had received the following bunch of files from GoDaddy after requesting for a certificate.

4d2e5dd927d67850.crt
4d2e5dd927d67850.pem
gd_bundle-g2-g1.crt
generated-csr.txt
generated-private-key.txt

So, I put the following config in nginx (after putting those files in /etc/nginx/ssl/sslcert/ directory)

ssl_certificate /etc/nginx/sslcert/4d2e5dd927d67850.crt;
ssl_certificate_key /etc/nginx/sslcert/4d2e5dd927d67850.pem;

But when I ran nginx -t, I got this error above.

Finally, was able to solve it because of this post from StackExchange.

Essentially, the .key file should have both the certificate and the key.

Renamed the 4d2e5dd927d67850.crt file to ssl.crt. This had, as usual –

-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----

Created a new file called ssl.key which had both the cert and the key –

-----BEGIN CERTIFICATE-----
 ...
-----END CERTIFICATE-----
-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----

And finally, the nginx configuration –

ssl_certificate /etc/nginx/sslcert/ssl.crt;
ssl_certificate_key /etc/nginx/sslcert/ssl.key;