Adding HTTPS/SSL to Node-RED

In this short post I will take you through the admin and config steps needed.

1. Create SSL certificate
2. Edit settings.js
3. Deal with wss (secure web sockets on iOS)

1. Create SSL certificate

We don’t want to send logon details over an un-encrypted connection. Node-RED needs a cetificate and key file to provide a SSL & WSS (Secure websocket connection). Change folder to public and enter the following to create SSL certs.

openssl genrsa -out privatekey.pem 1024
openssl req -new -key privatekey.pem -out private-csr.pem
openssl x509 -req -days 365 -in private-csr.pem -signkey privatekey.pem -out certificate.pem

2. settings.js

We need to make some changes to the Node-RED settings.js file

2.1 Add the following

 var fs=require('fs'); just before module.exports = {

2.2 Un comment https and add public/ to key and cert file references.

https: {
      key: fs.readFileSync(public/privatekey.pem'),
      cert: fs.readFileSync(public/certificate.pem')

2.3 Save edits

3.0 Workaround for wss issues on iOS

iOS doesn’t like self Signed SSL Certificates

Tip #1 – Don’t Accept your Self-Signed Certificate in Mobile Safari (that’s a one way street!)
Tip #2 – Email the certificate and the install it

Five Tips for Using Self Signed SSL Certificates with iOS via HTTPwatch
See Tip #2 for email certificate install