Nginx Startup Fails – SSL No Such File or Directory

debiannginxweb-server

Here is the error I'm getting:

Reloading nginx configuration: nginx: [emerg]
SSL_CTX_use_certificate_chain_file("/path/to/cert.pem") failed (SSL:
error:02001002:system library:fopen:No such file or directory
error:20074002:BIO routines:FILE_CTRL:system lib error:140DC002:SSL
routines:SSL_CTX_use_certificate_chain_file:system lib)
nginx: configuration file /etc/nginx/nginx.conf test failed

I'm 100% sure that the file is at that location but Nginx seems to think that it's not there.
I merged the domain.crt and intermediate.crt manually in that order.
I've been scratching my head over this one all day. I hope someone has seen this error and has a solution.(and a side note it's not an error in pasting that the file location is show only once and not again after 'no such file or directory').

Best Answer

Are you sure that the Nginx user has access to the directory?

Also check the permissions of the .pem file, if Nginx cannot access it, it can show as 'no such file or directory'.

If the permissions are right, you might check the actual path again. How you pasted it (which I know you removed the dir) there is no beginning / which could be the problem.

EDIT

Try moving your SSL setup into the following structure (as well as change the nginx.conf to reflect):

sudo mkdir /etc/nginx/ssl
sudo chown -R root:root /etc/nginx/ssl
sudo chmod -R 600 /etc/nginx/ssl

Nginx could be failing on your .pem because the permissions are too open (need source to verify that Nginx does this) but the above setup should work fine.