INSTAR Deutschland GmbHINSTAR Deutschland GmbH

Self-signed SSL certificate for the INSTAR MQTT Broker and Node-RED



Q: How do I use a custom SSL certificate for the INSTAR MQTT Broker with Node-RED?

A: We already showed how to set up your INSTAR MQTT Broker with a self-signed SSL cert. Following this guide we now have one camera configured as our MQTT Broker and a second cameras configured to be a MQTT Client on our MQTT network. Both cameras communicate SSL encrypted using a self-signed certificate.

Camera Setup

The broker camera is using the broker.pem file as SSL certificate:

Node-RED Self-Signed Cert for INSTAR MQTT

And is configured to use it's own MQTT broker (127.0.0.1) with a user login:

Node-RED Self-Signed Cert for INSTAR MQTT

Node-RED Setup

We can now continue by adding the broker to Node-RED:

Node-RED Self-Signed Cert for INSTAR MQTT

Add your broker cameras IP address and MQTT (TLS) port (default: 8883) and click to edit the TLS configuration.

Node-RED Self-Signed Cert for INSTAR MQTT

Now upload the client.pem file as the certificate for the broker connection.

Node-RED Self-Signed Cert for INSTAR MQTT

On the security tab you can add your broker user login.

Node-RED Self-Signed Cert for INSTAR MQTT

Node-RED Flow

We can now continue to add a few MQTT Nodes to control both of our cameras. Add a few MQTT topics with the MQTT ID of your cameras:

Node-RED Self-Signed Cert for INSTAR MQTT

This flow allows me to either, selectively activate or deactivate the 4 motion detection areas on each camera. Or switching all of them on or off using the "all" Topic:

Node-RED Self-Signed Cert for INSTAR MQTT

You can now switch to the Node-RED UI and give it a try:

Node-RED Self-Signed Cert for INSTAR MQTT

Node-RED JSON Flow Export

You can import this flow to your Node-RED dashboard. All you need to do to make it work is adding your personal MQTT Broker to all MQTT nodes and changing the MQTT ID that are used to address each camera:

[{"id":"61ef0727.5861e8","type":"comment","z":"f2874ee3.2c36e","name":"Multi Cam","info":"","x":80,"y":540,"wires":[]},{"id":"c3a24119.accef","type":"mqtt in","z":"f2874ee3.2c36e","name":"117 alarm/area1/enable","topic":"instar/10D1DC218F96/status/alarm/area1/enable","qos":"1","datatype":"auto","broker":"b37fd286.bdd28","x":120,"y":588,"wires":[["44093f9e.3ef07"]]},{"id":"44093f9e.3ef07","type":"ui_switch","z":"f2874ee3.2c36e","name":"Area 1","label":"Area 1","tooltip":"","group":"b4c0e313.f6a4f","order":0,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"instar/091419200118/alarm/area1/enable","style":"","onvalue":"{\"val\":\"1\"}","onvalueType":"str","onicon":"","oncolor":"","offvalue":"{\"val\":\"0\"}","offvalueType":"str","officon":"","offcolor":"","x":289,"y":588,"wires":[["2b72fc92.405c94"]]},{"id":"2b72fc92.405c94","type":"mqtt out","z":"f2874ee3.2c36e","name":"117 alarm/area1/enable","topic":"instar/10D1DC218F96/alarm/area1/enable","qos":"1","retain":"false","broker":"b37fd286.bdd28","x":471,"y":588,"wires":[]},{"id":"e1b10edd.1ba0d","type":"mqtt in","z":"f2874ee3.2c36e","name":"117 alarm/area2/enable","topic":"instar/10D1DC218F96/status/alarm/area2/enable","qos":"1","datatype":"auto","broker":"b37fd286.bdd28","x":120,"y":627,"wires":[["2f0b228d.d7fbee"]]},{"id":"2f0b228d.d7fbee","type":"ui_switch","z":"f2874ee3.2c36e","name":"Area 2","label":"Area 2","tooltip":"","group":"b4c0e313.f6a4f","order":0,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"instar/091419200118/alarm/area1/enable","style":"","onvalue":"{\"val\":\"1\"}","onvalueType":"str","onicon":"","oncolor":"","offvalue":"{\"val\":\"0\"}","offvalueType":"str","officon":"","offcolor":"","x":289,"y":627,"wires":[["3a2f05e9.f06eca"]]},{"id":"3a2f05e9.f06eca","type":"mqtt out","z":"f2874ee3.2c36e","name":"117 alarm/area2/enable","topic":"instar/10D1DC218F96/alarm/area2/enable","qos":"1","retain":"false","broker":"b37fd286.bdd28","x":471,"y":627,"wires":[]},{"id":"11f6be0a.933122","type":"mqtt in","z":"f2874ee3.2c36e","name":"117 alarm/area3/enable","topic":"instar/10D1DC218F96/status/alarm/area3/enable","qos":"1","datatype":"auto","broker":"b37fd286.bdd28","x":120,"y":667,"wires":[["446266e0.332f38"]]},{"id":"446266e0.332f38","type":"ui_switch","z":"f2874ee3.2c36e","name":"Area 3","label":"Area 3","tooltip":"","group":"b4c0e313.f6a4f","order":0,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"instar/091419200118/alarm/area1/enable","style":"","onvalue":"{\"val\":\"1\"}","onvalueType":"str","onicon":"","oncolor":"","offvalue":"{\"val\":\"0\"}","offvalueType":"str","officon":"","offcolor":"","x":289,"y":667,"wires":[["1bfca69d.b4ac79"]]},{"id":"1bfca69d.b4ac79","type":"mqtt out","z":"f2874ee3.2c36e","name":"117 alarm/area3/enable","topic":"instar/10D1DC218F96/alarm/area3/enable","qos":"1","retain":"false","broker":"b37fd286.bdd28","x":471,"y":667,"wires":[]},{"id":"95a60594.dc2e28","type":"mqtt in","z":"f2874ee3.2c36e","name":"117 alarm/area4/enable","topic":"instar/10D1DC218F96/status/alarm/area4/enable","qos":"1","datatype":"auto","broker":"b37fd286.bdd28","x":120,"y":707,"wires":[["8781da14.2efa48"]]},{"id":"8781da14.2efa48","type":"ui_switch","z":"f2874ee3.2c36e","name":"Area 4","label":"Area 4","tooltip":"","group":"b4c0e313.f6a4f","order":0,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"instar/091419200118/alarm/area4/enable","style":"","onvalue":"{\"val\":\"1\"}","onvalueType":"str","onicon":"","oncolor":"","offvalue":"{\"val\":\"0\"}","offvalueType":"str","officon":"","offcolor":"","x":289,"y":707,"wires":[["56c3148a.72c15c"]]},{"id":"56c3148a.72c15c","type":"mqtt out","z":"f2874ee3.2c36e","name":"117 alarm/area4/enable","topic":"instar/10D1DC218F96/alarm/area4/enable","qos":"1","retain":"false","broker":"b37fd286.bdd28","x":471,"y":707,"wires":[]},{"id":"f51f0525.a81ad8","type":"mqtt in","z":"f2874ee3.2c36e","name":"116 alarm/area1/enable","topic":"instar/10D1DC21F5DB/status/alarm/area1/enable","qos":"1","datatype":"auto","broker":"b37fd286.bdd28","x":120,"y":780,"wires":[["13bdd46e.5633ac"]]},{"id":"13bdd46e.5633ac","type":"ui_switch","z":"f2874ee3.2c36e","name":"Area 1","label":"Area 1","tooltip":"","group":"959e1975.f9b138","order":0,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"instar/000389888811/alarm/area1/enable","style":"","onvalue":"{\"val\":\"1\"}","onvalueType":"str","onicon":"","oncolor":"","offvalue":"{\"val\":\"0\"}","offvalueType":"str","officon":"","offcolor":"","x":289,"y":780,"wires":[["1df97bf7.99ba54"]]},{"id":"1df97bf7.99ba54","type":"mqtt out","z":"f2874ee3.2c36e","name":"116 alarm/area1/enable","topic":"instar/10D1DC21F5DB/alarm/area1/enable","qos":"1","retain":"false","broker":"b37fd286.bdd28","x":471,"y":780,"wires":[]},{"id":"a5ac0958.2b97c8","type":"mqtt in","z":"f2874ee3.2c36e","name":"116 alarm/area2/enable","topic":"instar/10D1DC21F5DB/status/alarm/area2/enable","qos":"1","datatype":"auto","broker":"b37fd286.bdd28","x":120,"y":819,"wires":[["2e5d3f2c.e1c5d"]]},{"id":"2e5d3f2c.e1c5d","type":"ui_switch","z":"f2874ee3.2c36e","name":"Area 2","label":"Area 2","tooltip":"","group":"959e1975.f9b138","order":0,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"instar/000389888811/alarm/area1/enable","style":"","onvalue":"{\"val\":\"1\"}","onvalueType":"str","onicon":"","oncolor":"","offvalue":"{\"val\":\"0\"}","offvalueType":"str","officon":"","offcolor":"","x":289,"y":819,"wires":[["936d0631.a57e68"]]},{"id":"936d0631.a57e68","type":"mqtt out","z":"f2874ee3.2c36e","name":"116 alarm/area2/enable","topic":"instar/10D1DC21F5DB/alarm/area2/enable","qos":"1","retain":"false","broker":"b37fd286.bdd28","x":471,"y":819,"wires":[]},{"id":"2d660b21.7f72f4","type":"mqtt in","z":"f2874ee3.2c36e","name":"116 alarm/area3/enable","topic":"instar/10D1DC21F5DB/status/alarm/area3/enable","qos":"1","datatype":"auto","broker":"b37fd286.bdd28","x":120,"y":859,"wires":[["7379cd9b.71c534"]]},{"id":"7379cd9b.71c534","type":"ui_switch","z":"f2874ee3.2c36e","name":"Area 3","label":"Area 3","tooltip":"","group":"959e1975.f9b138","order":0,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"instar/000389888811/alarm/area1/enable","style":"","onvalue":"{\"val\":\"1\"}","onvalueType":"str","onicon":"","oncolor":"","offvalue":"{\"val\":\"0\"}","offvalueType":"str","officon":"","offcolor":"","x":289,"y":859,"wires":[["fd1e8946.05a348"]]},{"id":"fd1e8946.05a348","type":"mqtt out","z":"f2874ee3.2c36e","name":"116 alarm/area3/enable","topic":"instar/10D1DC21F5DB/alarm/area3/enable","qos":"1","retain":"false","broker":"b37fd286.bdd28","x":471,"y":859,"wires":[]},{"id":"4351599b.296338","type":"mqtt in","z":"f2874ee3.2c36e","name":"116 alarm/area4/enable","topic":"instar/10D1DC21F5DB/status/alarm/area4/enable","qos":"1","datatype":"auto","broker":"b37fd286.bdd28","x":120,"y":899,"wires":[["ef7b24a2.79db68"]]},{"id":"ef7b24a2.79db68","type":"ui_switch","z":"f2874ee3.2c36e","name":"Area 4","label":"Area 4","tooltip":"","group":"959e1975.f9b138","order":0,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"instar/000389888811/alarm/area4/enable","style":"","onvalue":"{\"val\":\"1\"}","onvalueType":"str","onicon":"","oncolor":"","offvalue":"{\"val\":\"0\"}","offvalueType":"str","officon":"","offcolor":"","x":289,"y":899,"wires":[["35133b33.3d0d04"]]},{"id":"35133b33.3d0d04","type":"mqtt out","z":"f2874ee3.2c36e","name":"116 alarm/area4/enable","topic":"instar/10D1DC21F5DB/alarm/area4/enable","qos":"1","retain":"false","broker":"b37fd286.bdd28","x":471,"y":899,"wires":[]},{"id":"ad7bea57.2dc018","type":"mqtt out","z":"f2874ee3.2c36e","name":"all alarm/area1/enable","topic":"instar/all/alarm/area1/enable","qos":"1","retain":"false","broker":"b37fd286.bdd28","x":290,"y":999,"wires":[]},{"id":"799bc157.ec3d8","type":"ui_button","z":"f2874ee3.2c36e","name":"","group":"b0726aac.cd7738","order":4,"width":0,"height":0,"passthru":false,"label":"Areas On","tooltip":"","color":"","bgcolor":"","icon":"","payload":"{\"val\":\"1\"}","payloadType":"str","topic":"instar/all/alarm/area1/enable","x":79,"y":1060,"wires":[["ad7bea57.2dc018","33494e47.15c612","88d1c280.e6537","c051ddad.c946b"]]},{"id":"25a2feac.0e4a82","type":"mqtt out","z":"f2874ee3.2c36e","name":"all alarm/area1/enable","topic":"instar/all/alarm/area1/enable","qos":"1","retain":"false","broker":"b37fd286.bdd28","x":289,"y":1177,"wires":[]},{"id":"99e2c1a8.2b636","type":"ui_button","z":"f2874ee3.2c36e","name":"","group":"b0726aac.cd7738","order":4,"width":0,"height":0,"passthru":false,"label":"Areas Off","tooltip":"","color":"","bgcolor":"","icon":"","payload":"{\"val\":\"0\"}","payloadType":"str","topic":"instar/all/alarm/area1/enable","x":79,"y":1240,"wires":[["25a2feac.0e4a82","cc0c95c4.d6f4f8","699e04aa.e26d5c","14281fe7.cceda"]]},{"id":"33494e47.15c612","type":"mqtt out","z":"f2874ee3.2c36e","name":"all alarm/area2/enable","topic":"instar/all/alarm/area2/enable","qos":"1","retain":"false","broker":"b37fd286.bdd28","x":290,"y":1039,"wires":[]},{"id":"cc0c95c4.d6f4f8","type":"mqtt out","z":"f2874ee3.2c36e","name":"all alarm/area2/enable","topic":"instar/all/alarm/area2/enable","qos":"1","retain":"false","broker":"b37fd286.bdd28","x":289,"y":1217,"wires":[]},{"id":"88d1c280.e6537","type":"mqtt out","z":"f2874ee3.2c36e","name":"all alarm/area3/enable","topic":"instar/all/alarm/area3/enable","qos":"1","retain":"false","broker":"b37fd286.bdd28","x":290,"y":1079,"wires":[]},{"id":"699e04aa.e26d5c","type":"mqtt out","z":"f2874ee3.2c36e","name":"all alarm/area3/enable","topic":"instar/all/alarm/area3/enable","qos":"1","retain":"false","broker":"b37fd286.bdd28","x":289,"y":1257,"wires":[]},{"id":"c051ddad.c946b","type":"mqtt out","z":"f2874ee3.2c36e","name":"all alarm/area4/enable","topic":"instar/all/alarm/area4/enable","qos":"1","retain":"false","broker":"b37fd286.bdd28","x":290,"y":1119,"wires":[]},{"id":"14281fe7.cceda","type":"mqtt out","z":"f2874ee3.2c36e","name":"all alarm/area4/enable","topic":"instar/all/alarm/area4/enable","qos":"1","retain":"false","broker":"b37fd286.bdd28","x":289,"y":1297,"wires":[]},{"id":"b37fd286.bdd28","type":"mqtt-broker","z":"","name":"192.168.2.117 (PrivCert)","broker":"192.168.2.117","port":"8883","tls":"7d9f372e.6892b8","clientid":"nodered","usetls":true,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"b4c0e313.f6a4f","type":"ui_group","z":"","name":"Alarm Areas 117","tab":"a28030c1.b97b8","disp":true,"width":"6","collapse":false},{"id":"959e1975.f9b138","type":"ui_group","z":"","name":"Alarm Areas 116","tab":"a28030c1.b97b8","disp":true,"width":"6","collapse":false},{"id":"b0726aac.cd7738","type":"ui_group","z":"","name":"Alarm Areas All","tab":"a28030c1.b97b8","disp":true,"width":"6","collapse":false},{"id":"7d9f372e.6892b8","type":"tls-config","z":"","name":"192.168.2.117 (PrivCert)","cert":"","key":"","ca":"","certname":"client.pem","keyname":"","caname":"","servername":"","verifyservercert":false},{"id":"a28030c1.b97b8","type":"ui_tab","z":"","name":"Multi Cam","icon":"dashboard","disabled":false,"hidden":false}]

Now you can continue with our regular tutorial to add your first switches and automations.