Enable HTTPS with Wildcard SSL Certificate

Hi All,

I want to enable the https of Node-red but my tech only provided me a wildcard ssl and only 1 pem key. based on the documentation, I need the Private and Cert Chain in PEM key. How can I use this one?

Are you saying that they only provided a single file?

You need a public key file and a private certificate file - these HAVE to be separate in use.

Maybe they are expecting you to generate a key file?

I'm not certain as I've not done it, but I think you can generate the public key using this command:

openssl x509 -pubkey -noout -in cert.pem  > pubkey.pem

To add to the possibilities here.
you can also use a certificate/key exchange file (as I do)

https: {
     pfx: require('fs').readFileSync('~/certs/certificate.p12'),
     passphrase: 'some-password'

I tried both of your suggestion but it didn't worked. Here's my code...

  requireHttps: true,
  https: {
    key: require("fs").readFileSync('C:/Users/wshostak/.node-red/certs/e2private.pem'),
    cert: require("fs").readFileSync('C:/Users/wshostak/.node-red/certs/pubkey.pem')
  // https: {
  //   pfx: require('fs').readFileSync('C:/Users/wshostak/.node-red/certs/e2ccwildcard.pfx'),
  //   passphrase: "password here."
  // }

@marcus-j-davies @TotallyInformation

Did you see any errors when you restarted node-red ?

At the top of your NR settings.js file .. did you uncomment fs ??

// The `https` setting requires the `fs` module. Uncomment the following
// to make it available:
var fs = require("fs");

I only have this code:

  functionGlobalContext: {
    fs: require('fs'),
    luxon: require('luxon-business-days')

those are settings for Function nodes to be able to use modules

At the top of settings.js you have to uncomment var fs = require("fs");
so the settings.js file can require fs and read the private and public keys

Actually I dont have that variable declaration at all. I tried adding it but still didn't work

I think It might be worth ruling out Node Red its self - although I cant imagine why it would have problems

Here is a self signed cert.
Use it as follows

 https: {
    key: require("fs").readFileSync('C:/Users/wshostak/.node-red/certs/26599750_node-red.key.txt'),
    cert: require("fs").readFileSync('C:/Users/wshostak/.node-red/certs/26599750_node-red.cert.txt')

If this works, then I think there might be something up with with the certificate you have maybe :man_shrugging:

26599750_node-red.key.txt (1.6 KB)
26599750_node-red.cert.txt (1013 Bytes)

Also note: that Node RED secures port 1880 - so you will need.
https://...:1880 not https://...:443 <-- default for SSL. at least that is what happens to me.

I must have been using an older settings.js file that had the require of fs at the top
apologies .. i later noticed that with require("fs").readFileSync
fs was required and used on the same code line .. doh

It's working now! I'm having error because I'm not using the 1880 port. Thaaaaaanks!

1 Like

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