-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MQTT TLS] Add TLS support for MQTT #3788
Conversation
This may prevent additional calls to load the CSS from the file system in a separate HTTP GET call and also not loading the file into memory when streaming.
Making it easier for users to copy/paste certificate code into a file. It will be patched at load from the file system.
There is a memory leak in Mbed TLS, when connection failed. For example when using a CA root certificate which does not match the certificate of the host we're connecting to. This will take about 1880 bytes of memory on each attempt. Still a work-in-progress as it is not yet fixed.
Otherwise you may not always use the latest CA root certificate stored on the file system
In a lot of places an object was allocated on the heap, but not always it was deleted thus leading to memory leaks.
I made an error in previous commit for this PR
Hi @TD-er What about MQTT_TLS? Can I test a firmware with that feature? |
Yep. N.B. keep in mind there currently is NO validation of certificates, so a man-in-the-middle attack is still possible without you notice it. |
Hi @TD-er, Interesting work man, I was really looking into MQTT TLS in ESP-Easy |
Right now I only have been using username/password for connecting to a MQTT broker. N.B. please note that since I'm now using a stripped down version of BearSSL, I have disabled actually checking the server side certificate. Initially I did add quite a lot of those checks, fetching certificates, CA, fingerprint, etc. And since this PR was 'pending' way too long, I now decided to merge it so it is usable and we can see what is actually used by users and add it. Can you make a new issue for your cert-based connecting to MQTT broker? |
ESP8266 running TLS is adviced to run at 160 MHz.
Tested this frequency, it does seem to work quite OK, so that may be useful for other use cases too.
Power consumption increases with roughly 5 - 7 mA between 80 MHz and 160 MHz.
Currently this does not work on ESP8266 as it continuously runs out of memory.
Maybe when using 2nd heap on core 3.0.0 this may be usable.
ESP32 does seem to work just fine. (tested with Mosquitto)
Included is a selector (in the controller settings) to just allow any TLS certificat presented. Nothing will be checked, thus it is a perfect receipe for a man-in-the-middle attack.
Work-in-progress on adding support for PSK (Pre-Shared-Key), which is supported by Mosquitto.
But it is not widely used along with TLS and so far I have not found other MQTT brokers which support TLS/PSK.
Other options in development:
Fixes: #2271
Fixes: #4783