The latest is 1.13.0 Release includes a port the MQTT over SSL support from the JSON IoT Agent over to the Ultralight IoT Agent.
The important changes for secure MQTT support can be found here - the most relevant part is summarized below:
var options = {
protocol: 'mqtt',
host: 'localhost',
port: 1883,
key: fs.readFileSync(mqttConfig.key, 'utf8') : null,
ca: fs.readFileSync(mqttConfig.ca, 'utf8') : null,
cert: fs.readFileSync(mqttConfig.cert, 'utf8') : null,
rejectUnauthorized: true,
username: 'username',
password: 'password',
keepalive: 0,
connectTimeout: 60 * 60 * 1000
};
var mqttClient = mqtt.connect(
options.protocol + '://' + mqttConfig.host + ':' + mqttConfig.port,
options
);
This is merely stuffing the options available within the standard Node.JS MQTT Client
Since this PR has been merged,it is now possible to use the latest docker image and supply Docker variables to add username, password, ca authority and so on.
The following new Docker ENV variables are defined:
| Environment variable | Configuration attribute |
| ---------------------------- | ---------------------- |
| IOTA_MQTT_PROTOCOL | mqtt.protocol |
| IOTA_MQTT_CA | mqtt.ca |
| IOTA_MQTT_CERT | mqtt.cert |
| IOTA_MQTT_KEY | mqtt.key |
| IOTA_MQTT_REJECT_UNAUTHORIZED | mqtt.rejectUnauthorized |
| IOTA_MQTT_USERNAME | mqtt.username |
| IOTA_MQTT_PASSWORD | mqtt.password |
IOTA_MQTT_KEY, IOTA_MQTT_USERNAME and IOTA_MQTT_PASSWORD can be hidden as Docker secrets and alias in the usual manner by adding the _FILE suffix.