Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node.js FS cannot read certificate from letsencrpyt

const httpsOptions = {
    key: FS.readFileSync("/etc/letsencrypt/live/site/privkey.pem"),
    cert: FS.readFileSync("/etc/letsencrypt/live/site/fullchain.pem")
};

EACCES: permission denied

Trying to set up a HTTPS server with options. While setting up the optiosn to pass to the HttpS.createServer(httpsOptions,App);. I got the cert from letsencrypt however trying to run the server results in permission denied errors. What is the correct way to load the cert and key file for the HTTPS server?

like image 599
kabuto178 Avatar asked Feb 12 '18 20:02

kabuto178


2 Answers

@Wesgur answer did not help in my case, what did help was:

sudo chown $(whoami) /etc/letsencrypt/live/ -R
sudo chown $(whoami) /etc/letsencrypt/archive/ -R

Probably related to the fact that the live directory .pem files are symbolic links to the actual certificate and private key files in the archive directory...

like image 150
Cel Avatar answered Nov 02 '22 23:11

Cel


The certificates doesn't have right permissions.

sudo chmod 755 /etc/letsencrypt/live/

Try this. Hope it works

like image 24
Wesgur Avatar answered Nov 02 '22 23:11

Wesgur