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
Posts: 61
Joined: Mon Jul 19, 2021 1:41 am

Check out this post: viewtopic.php?f=20&t=350
User avatar
myVesta
Site Admin
Posts: 756
Joined: Fri Jun 19, 2020 9:59 am

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