I'm running SSL Certificates from Let's Encrypt. I've got them installed on my Ubuntu machine running Apache. The setup works fine and I can launch the website, see the green padlock and even got an A+ on SSL Labs.
The problem is that when I do apachectl configtest the server would return a file not found error:
SSLCertificateFile: file '/etc/letsencrypt/live/www.example.com/fullchain.pem' not exist or is empty.
But sudo service apache2 restart
works just fine.
I got this question running at Let's Encrypt Community but the issue hasn't been resolved yet.
sudo cat /etc/letsencrypt/live/www.example.com/fullchain.pem
works, returns valid certificate details.
sudo x509 -text -noout -in /etc/letsencrypt/live/www.example.com/fullchain.pem
does not work and returns the error below:
Error opening Certificate /etc/letsencrypt/live/www.example.com/fullchain.pem
139774254929568:error:02001002:system library:fopen:No such file or directory:bss_file.c:398:fopen('/etc/letsencrypt/live/www.example.com/fullchain.pem.','r')
139774254929568:error:2007402:BIO routines:FILE_CTRL:system lib:bss_file.c:400:
ubable to load certificate
Any ideas on why I'm getting errors on apachectl configtest and openssl?
Thanks guys!
In my case the files and permissions where not the issue. I was trying to restart the server with
apachectl restart
or test the config (apachectl -t
orapachectl configtest
). The user running the command (me) simply didn't have the proper permissions to access the certificates. I just had to prefix the commands withsudo
to run them as root! No more errors, the config test returns "Syntax OK" and I can restart the server. (OK I'm a bit embarrassed it took me so long to figure that one out...)After several sleepless nights, I finally got it to work. (overkill statement) We all know it was permissions, but exactly where was something to check.
I kept on working with /ect/letsencrypt/live and the directories and files under that. I kept changing permissions from the original to 0755 and 0777. What I did not immediately see was that /etc/letsencrypt/live was a link created from /etc/letsencrypt/archive and it had a 0700 permission. That's why it wasn't able to read the file. After changing the permission of /etc/letsencrypt/archive to 0755,
apachectl configtest
already responded withSyntax OK
.Although the original issue was resolved, I will refer this back to Let's Encrypt because this was all Auto Installation of Certificates. Something like this should not happen in "auto". But my setup might have something to do with the permission issue since I installed it using a non-root user (but I did sudo).
Hope this helps someone.
Agreeing with timeSmith's answer that the permissions on these files and folders are intentionally tight, and should be left as
0700
.You need to run
service httpd
orapachectl
commands assudo
so that these processes have root privileges and get read access to the letsencrypt certificate folders and files.As originally commented by Ian Terle, changing the permissions on the "live" directory now fixes the issue:
Note: I was observing the same error as the OP.
This was confirmed on:
Ubuntu 16.04.2 LTS
Apache/2.4.18 (Ubuntu)
The permissions on the cert files are best left very tight. To allow the appropriate processes access to the cert files: start apache using the following commands.
Alternately restart gracefully using this command: