Unable to secure node-red over https using self signed certs

I create certificates using the following commands:
I use localhost as the common-name for the second command

openssl genrsa -out node-key.pem 2048
openssl req -new -sha256 -key node-key.pem -out node-csr.pem
openssl x509 -req -in node-csr.pem -signkey node-key.pem -out node-cert.pem

and modify my settings as

requireHttps: false,
    https: {
        key: fs.readFileSync('./certs/node-key.pem'),
        cert: fs.readFileSync('./certs/node-cert.pem'),
        ca: fs.readFileSync('./certs/node-csr.pem')
    },

I start node-red

// Create a server
let server = http.createServer(app);

// Initialise the runtime with a server and settings
RED.init(server, settings);

// Serve the editor UI from /red
app.use(settings.httpAdminRoot, RED.httpAdmin)

// Serve the http nodes UI from /api
app.use(settings.httpNodeRoot, RED.httpNode)

server.listen(1880, async (error) => {
    // Start the runtime
    await RED.start()
})

Then hit the url: https://localhost:1880/red/
And face the error:

ERR_SSL_PROTOCOL_ERROR

What am I doing wrong?

Is there a reason you are trying to start Node-RED yourself rather than letting the normal startup and TLS config do the work for you?

This will be one error. You are creating an http server, not an https server.

You need to swap in the https module for the http module.

I switched http to https (my bad!).
And now the error is - ERR_SSL_VERSION_OR_CIPHER_MISMATCH

Yes. need to run it along with some other services

I suggest googling that error to see what it means.

For example: https://kinsta.com/knowledgebase/err_ssl_version_or_cipher_mismatch/

Will try and get back. I am surprised no one hasnt had this issue with node-red

Got it. Since I was using a custom express app:

let app = express();
let server = http.createServer({
    key: fs.readFileSync('./certs/node-key.pem'),
    cert: fs.readFileSync('./certs/node-cert.pem'),
    ca: fs.readFileSync('./certs/node-csr.pem')

},

I must include the cert info while creating the server. The following doesnt work because the server is already created by that time!

RED.init(server, settings);

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