Page 1 of 1
How to make SSL cert file readable for NodeJS
Posted: Mon Oct 24, 2022 4:30 pm
by mylastore
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'
Re: How to read SSL cert and key
Posted: Tue Oct 25, 2022 5:25 pm
by isscbta
Re: How to read SSL cert and key
Posted: Thu Oct 27, 2022 1:36 pm
by myVesta
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.