NodeRED not finding certificates

Hey everyone reading this.
I am currently trying to crate a subdomain for my NodeRED Webinterface.
Since I am using cloudflare i wanted/ need to secure my Webinterface through HTTPS
Therefore i commented out the first Option in the settings.js and pasted the crtificate.pem and privatekey.pem in /mynodered/_data/ (i am running NodeRED in Docker) but every time i try to run the container i get the following error:

Error loading settings file: /data/settings.js
Error: ENOENT: no such file or directory, open 'privatekey.pem'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at Object.<anonymous> (/data/settings.js:94:26)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/usr/src/node-red/node_modules/node-red/red.js:140:20) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: 'privatekey.pem'

from this i am reading that it can't find the private key but it is in the same directory as the settings. Can anybody help me out finding a way to solve this error and secure the Webinterface over HTTPS?
Best Regards Justricity

You should add the full path in the settings.js file.
Like this:

/** Option 1: static object */
    https: {
      key: require("fs").readFileSync('/data/node-key.pem'),
      cert: require("fs").readFileSync('/data/node-cert.pem')
    },

Tested in docker without path I got exactly your error, with path it works.

thanks it works now or at least its not crashing anymore and stays up running. But still coudflare presents me a page that the webserver is down even though it's up but ig for that topic here is not the right place for it.
Although if anyone is interested i have my domain proxied through cloudflare and my subdomain node.domain.de points to my proxy wich proxys it through to my main server on port 1880. Since my SSL/TLS settings are set to full and have a certificate for nodered but it still shows me a HTTP ERROR:521

Easy fix :slight_smile:

Error 521... is your certificate signed by a publicly trusted authority?

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