How to make SSL cert file readable for NodeJS

Post Reply
mylastore
Posts: 4
Joined: Mon May 31, 2021 3:46 am

I am trying run https on a nodejs application so when I try to read for example

Code: Select all

/home/admin/conf/web/ssl.papaslive.crt'
I get the following permissions error:

Code: Select all

Error: EACCES: permission denied, open '/home/admin/conf/web/ssl.papaslive.com.key'
User avatar
isscbta
Team Member
Posts: 130
Joined: Mon Jul 19, 2021 1:41 am
Has thanked: 15 times
Been thanked: 3 times

Check out this post: viewtopic.php?f=20&t=350
User avatar
myVesta
Site Admin
Posts: 928
Joined: Fri Jun 19, 2020 9:59 am
Has thanked: 8 times
Been thanked: 6 times

Run as root in SSH:

Code: Select all

echo "UPDATE_SSL_SCRIPT='/usr/local/bin/update_ssl_script.sh'" >> /usr/local/vesta/conf/vesta.conf
This is callback that will run script every time when some SSL is generated/renewed.

Than make the script that will be triggered:

Code: Select all

cat <<EOF >/usr/local/bin/update_ssl_script.sh
#!/bin/bash
chmod -R a+r /home/admin/conf/web/
# change 'admin' to other username if domain is not under 'admin' account
EOF

chmod a+x /usr/local/bin/update_ssl_script.sh
Now run that script manually:

Code: Select all

/usr/local/bin/update_ssl_script.sh
This will make your certificate files readable for all linux users, so NodeJS can read it.

After LetsEncrypt auto-renewing, /usr/local/bin/update_ssl_script.sh will be triggered.
Post Reply