W
W
WebDev2020-06-07 23:02:57
Digital certificates
WebDev, 2020-06-07 23:02:57

How to correctly use a certificate for a websocket connection?

I use a certificate from Letsencrypt for the domain. The certificate is in '/etc/letsencrypt/live/mysite/privkey.pem'.
The certificate itself is updated and everything is fine.
But in addition to the site itself, I also have a nodejs service running with a websocket. To make the connection to the websocket also secure, I copied the site certificates to the folder with the service.

const key   = fs.readFileSync('ssl-cert/privkey.pem', 'utf8');
const cert  = fs.readFileSync('ssl-cert/fullchain.pem', 'utf8');
const server = require('https').createServer({key, cert}, app);

The problem is that when the certificate expires, you have to manually copy the files from the letsencrypt directory again.
I also cannot specify the original certificate in the application, because it runs from www-data, and to access the certificate, you need to run it as root.
I tried to make files in ssl-cert links to the original, but apparently this is not possible. Swears. There was a variant on krone to copy the certificate time in 3 months.
How right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Gavrilov, 2020-06-07
@thexaver

You can proxy through nginx and, for example. use cloud and infinite ssl

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question