I need to connecto to my broker with SSL/TLS Version = Auto and SSL/TLS Certificate Type = CA signed server certificate
From the README:
In case mqtts (mqtt over tls) is required, the
optionsobject is
passed through totls.connect().
From those docs for tls.connect(), click on tls.createSecureContext() where it says:
...:
tls.createSecureContext()options that are used if the secureContext option is missing,
Now you can see you need to pass in a ca property containing the loaded certificate from your CA.
hello guys! this
In case mqtts (mqtt over tls) is required, the options object is passed through to tls.connect().
really makes me feel like a noob!
I really can't figure out how to use my ca.crt to connect to the mosquitto
Here is a working example:
const mqtt = require('mqtt');
const fs = require('fs');
const client = mqtt.connect('mqtts://test.mosquitto.org', {
ca: fs.readFileSync('mosquitto.org.crt'),
});
client.on('connect', () => {
console.log('connected');
});
You can get mosquitto.org.crt from here: https://test.mosquitto.org/ssl/mosquitto.org.crt
hey @jdiamond in case of a CA generated locally with openSSL will passing it in options.ca be fine ?
Yeah, doesn't matter who generated it as long as it's in the right format and valid. That's probably how the mosquitto cert was generated.