Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - simpli

Pages: [1]
1
Addons / nodejs SSL
« on: July 02, 2021, 01:57:11 PM »
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:-
Code: [Select]
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.

Pages: [1]