feat: add optional TLS support for MQTT connections#804
Open
jviets wants to merge 1 commit intoBlueforcer:mainfrom
Open
feat: add optional TLS support for MQTT connections#804jviets wants to merge 1 commit intoBlueforcer:mainfrom
jviets wants to merge 1 commit intoBlueforcer:mainfrom
Conversation
Contributor
|
If this ever get accepted by @Blueforcer I would suggest to make this also a compile time option. Flash and RAM are limited and a compile time option allows to remove any unused functionality from firmware image. Most of us do not need TLS in private IoT networks. |
Author
|
Hey @eku, fair enough! I implemented this for my specific use case and have successfully compiled, flashed, and deployed it on my device. I'm simply offering this PR in case it benefits the project. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds optional TLS support for MQTT connections, enabling secure communication with brokers that require TLS (e.g., HiveMQ Cloud on port 8883).
Changes
WiFiClientSecurealongsideWiFiClientfor runtime selection based on configMQTT_TLSconfig variable: New boolean inGlobals.h/cpp, persisted inDoNotTouch.jsonHAMqttconstruction from global scope toMQTTManager::setup()to allow runtime client selection (secure vs plain)mqttPtrnull checks inpublish(),rawPublish(),tick(),beginPublish(),writePayload(),endPublish()to prevent crash if MQTT methods are called beforesetup()upload_speedto 115200 for more reliable serial flashingUsage
8883(or your broker's TLS port)Uses
setInsecure()mode (no certificate verification) to keep flash size minimal while still encrypting the connection.Testing