-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add support for secure MQTT connections with TLS #106
Conversation
WiFiClientSecure espClient; | ||
// ************ Let's encrypt CA Root Certificate ***************** | ||
// Valid To 04 Jun 2035 | ||
const char *SSL_CA_PEM = "-----BEGIN CERTIFICATE-----\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there anything to be said against not embedding the certificate in the code but reading it from the file system instead? Or at least include it from a user config header file here and leave it up to the user to decide which Root CA is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a good idea to load the cert from a PEM file in the data partition. I will modify the code and test it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a good idea to load the cert from a PEM file in the data partition.
If the cert expires, the code does not have to be recompiled and flashed.
How much extra flash consumes the certificate + Secure client? It may be worth checking if this fits into existing partition table for 4M Flash version. And adding a note in the Config file next to the |
…lt root CA cert from Let's Encrypt
Cert is ~2k and now in the data folder. No problem to store it there. Code with secure client needs a bit more space in the app partition. Other settings are no relevant to see the increase for the sec client. The pem file can be deleted, if no TLS is used. So don't know, if it should be there as default. Limited amount of user will need it, I guess. What are your thoughts? |
Secure client adds ~500 bytes to the app size. That's fine. My suggestions:
|
Would be falling back to unencrypted communication an option? |
That would mean that firmware has to load both TCP clients (unencrypted and secure) and then on the fly switch between them. Waste of Flash and RAM. |
…AVE_PREFERENCES_AFTER_SEC up - changed filenmae for CA root cert - Added check if file exists - Moved CA file as example to 'data - other graphics' folder
Done
Done |
All what aly-fly mentioned is true. And in the moment, there can only be one port defined and that means, TLS or no TLS as well, so it is this or that, never both. |
Add support for secure MQTT connections with TLS.
Now it is possible to connect to MQTT broker with TLS support, like HiveMQ or a local Mosquitto, with TLS enabled.
Note: HiveMQ is one of the internet-based brokers, which supports Home Assistant messages and can be used.