14
votes

I am tying to use GoDaddy ssl with Nginx. I am having and issue getting this to work. Any help would be appreciated.

I did the following:

openssl req -new -newkey rsa:2048 -nodes -keyout img.example.com.key -out img.example.com.csr

Gave this to GoDaddy and requested a new cert.

Next I combined the two crt files into one.

Assuming your certificate file is called example.com.crt, use this command to create a combined file called example.com.chained.crt (replace the highlighted part with your own domain):

cat example.com.crt intermediate.crt > example.com.chained.crt

server_name example.com;
ssl_certificate /home/sammy/example.com.chained.crt;
ssl_certificate_key /home/sammy/example.com.key;

I am now seeing this error when I try to start Nginx:

sudo nginx -t

nginx: [emerg] SSL_CTX_use_PrivateKey_file("/etc/nginx/ssl-certs/img.example.com.key") failed (SSL: error:0906D06C:PEM routines:PEM_read_bio:no start line:Expecting: ANY PRIVATE KEY error:140B0009:SSL routines:SSL_CTX_use_PrivateKey_file:PEM lib)

Anyone know why I am getting this error?

Thanks Phil

2

2 Answers

33
votes

Had the same issue. Changing the encoding from UTF-8 to ANSI did work for me.

5
votes

Notepad++ encoding from UTF-8 to ANSI did it for me. Change Encoding, saved, scp / winscp / copy to server. done.

The Unix version of this is to save time with copy processes:

iconv -c -f UTF8 -t ASCII  /etc/nginx/certs/genprivkey.key >> /etc/nginx/certs/genprivkey.key

enter image description here