mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-20 09:43:03 +00:00
Add MQTT TLS Support for WIFI-Enabled Devices (#2410)
* Testing TLS MQTT Support * Working TLS connections * Testing TLS MQTT Support * Working TLS connections * Added protobuf support for mqtt.tls_enabled * fix 'em up good * don't commit this stuff, jeeez * there i fixed it --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com>
This commit is contained in:
@@ -192,6 +192,26 @@ void MQTT::reconnect()
|
||||
mqttPassword = moduleConfig.mqtt.password;
|
||||
}
|
||||
|
||||
#if HAS_WIFI && !defined(ARCH_PORTDUINO)
|
||||
if (moduleConfig.mqtt.tls_enabled) {
|
||||
// change default for encrypted to 8883
|
||||
try {
|
||||
serverPort = 8883;
|
||||
wifiSecureClient.setInsecure();
|
||||
|
||||
pubSub.setClient(wifiSecureClient);
|
||||
LOG_INFO("Using TLS-encrypted session\n");
|
||||
} catch (const std::exception &e) {
|
||||
LOG_ERROR("MQTT ERROR: %s\n", e.what());
|
||||
}
|
||||
} else {
|
||||
LOG_INFO("Using non-TLS-encrypted session\n");
|
||||
pubSub.setClient(mqttClient);
|
||||
}
|
||||
#else
|
||||
pubSub.setClient(mqttClient);
|
||||
#endif
|
||||
|
||||
String server = String(serverAddr);
|
||||
int delimIndex = server.indexOf(':');
|
||||
if (delimIndex > 0) {
|
||||
@@ -528,4 +548,4 @@ std::string MQTT::downstreamPacketToJson(meshtastic_MeshPacket *mp)
|
||||
|
||||
delete value;
|
||||
return jsonStr;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user