Hi there,
I hope someone can advise me on the nodejs SSL issue with private key and certificate file permission denied.
My current code as follow:-
const hostname = 'domain.com';
const port = 300;
const fs = require('fs');
const privateKey = fs.readFileSync("/etc/pki/tls/private/domain.com.key", 'utf8')
const certificate = fs.readFileSync("/etc/pki/tls/certs/domain.com.cert", 'utf8')
const credentials = {
key: privateKey,
cert: certificate
}
const httpServer = require('https').createServer( credentials, (req, res) => {
res.statusCode = '200';
res.setHeader('Content-Type', 'text/plain');
res.end('Welcome port '+ port)
} );
httpServer.listen(port, hostname, () => {
console.log('listening to : '+ port);
});
If i try to point to /etc/pki/tls folders this app will prompt permission denied error.
Currently, i manually copy these files to the app folder and i have to keep repeating this process everytime the AutoSSL expired.
Please advise how may i use this files without manually copy it into the app folder.
Thank you in advance.
Stay home and stay safe.