Setup HTTPS - Help Please

Trying to turn on HTTPS. I have attempted a few guides at doing this and have created the PEM files.
I then modify settings.js file and have tried to use option 1 and option 2 but nothing seems to work.

The one difference I have is that I have 2 node-red installed locally. I am also using a daemond to start them up. For example:

ExecStart=/usr/bin/node /home/administrator/nr1/node_modules/node-red/red.js -s /home/administrator/nr1/node_modules/node-red/settings.js

My settings.js looks like this:
/** Option 1: static object */
https: {
key: require("fs").readFileSync('/certs/node-key.pem'),
cert: require("fs").readFileSync('/certs/node-cert.pem')
},

the "certs" folder is in /home/administrator/nr1/certs/. I have verified that I have the 2 files node-key.pem and node-cert.pem inside that folder.

Any idea as to what I have done wrong?
systemctl status nr1 (the name of my daemon) shows:

 nr1.service - Node-Red for NR1
     Loaded: loaded (/etc/systemd/system/nr1.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Thu 2022-12-08 19:03:04 UTC; 13s ago
       Docs: http://nodered.org/docs
   ` Process: 1228 ExecStart=/usr/bin/node /home/administrator/nr1/node_modules/node-red/red.js -s /home/administrator/nr1/node_modules/node-red/settings.js (code=exited, status=0/SUCCESS)
   Main PID: 1228 (code=exited, status=0/SUCCESS)
        CPU: 1.310s

Dec 08 19:03:04 nodered node[1228]:     at Module.require (internal/modules/cjs/loader.js:887:19)
Dec 08 19:03:04 nodered node[1228]:     at require (internal/modules/cjs/helpers.js:74:18)
Dec 08 19:03:04 nodered node[1228]:     at Object.<anonymous> (/home/administrator/nr1/node_modules/node-red/red.js:140:20) {
Dec 08 19:03:04 nodered node[1228]:   errno: -2,
Dec 08 19:03:04 nodered node[1228]:   syscall: 'open',
Dec 08 19:03:04 nodered node[1228]:   code: 'ENOENT',
Dec 08 19:03:04 nodered node[1228]:   path: '/certs/node-key.pem'
Dec 08 19:03:04 nodered node[1228]: }
Dec 08 19:03:04 nodered systemd[1]: nr1.service: Deactivated successfully.
Dec 08 19:03:04 nodered systemd[1]: nr1.service: Consumed 1.310s CPU time.

Really new to these things so any ideas are appreciated.

Also, the systemd service is set to run as "Administrator" so I assume it should have access the the certificate files.

You have not shared the whole error so we can't see what caused it. An open error usually means that the file isn't where you think it is.

No worries, thanks for the response. However, I did give the error.
The error is coming from Linux when attempting to start the systemd I built.
I think it is related to "at Object. (/home/administrator.....

I agree that it thinks it can't find the file...but I cant determine why.

Would this be what you are looking for.

root@nodered:/etc/systemd/system# /usr/bin/node /home/administrator/nr1/node_modules/node-red/red.js -s /home/administrator/nr1/node_modules/node-red/settings.js
Error loading settings file: /home/administrator/nr1/node_modules/node-red/settings.js
Error: ENOENT: no such file or directory, open 'node-key.pem'
    at Object.openSync (fs.js:462:3)
    at Object.readFileSync (fs.js:364:35)
    at Object.<anonymous> (/home/administrator/nr1/node_modules/node-red/settings.js:94:26)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/administrator/nr1/node_modules/node-red/red.js:140:20) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: 'node-key.pem'
}
root@nodered:/etc/systemd/system#

Yes. And the error is pretty clear. no such file or directory for /certs/node-key.pem.

If you type ls -la /certs/node-key.pem what do you get? Or even ls -la /certs?

If you get a result, look carefully at the file ownership and make sure that whatever user/group is running node-red actually has access to the file and folder.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.