-
Notifications
You must be signed in to change notification settings - Fork 270
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 encrypted TLS connection support using certificates or PSK #266
base: master
Are you sure you want to change the base?
Conversation
This is required for successful compilation in ESP32. This effectively disables fingerprint functionality on ESP32. Hopefully this will be restored in a future commit.
No point exposing a non-working API on ESP32.
This support simply forwards the setRootCa from AsyncTCP. Compatible with most AsyncTCP forks as well as AsyncTCPSock.
As with the previous commit, this simply forwards the existing support in AsyncTCP/AsyncTCPSock. Expected to be required to attempt connecting to Google Cloud or Amazon AWS servers.
nice. I'll try it out too... |
Hi @avillacis, What I saw is that the SSL options are disabled by default via the
This parameter is not mentioned anywhere in the AsyncTCP library (it is mentioned but not activated for the ESP8266). So the question is where should you define ASYNC_TCP_SSL_ENABLED to be able to use PSK in an ESP32? |
Sorry, my library was missing the official method to enable compile macros in Arduino. This is fixed now at yubox-node-org/AsyncTCPSock@9f82a7e . In Arduino IDE, the official method to enable compile macros is to create a new file in the sketch project, with the name
Multiple macros may be defined in this way, one per line. |
The quick fix is really apreciated :) For anyone on the same situation as me: I'm using platformIO, to enable the macro that @avillacis is mentioning you just have to add on the platform.ini file the following configuration:
Now that everything compiles with the setPSK() method I've created a sketch to test functionality:
However if I upload the code on the ESP32 I get:
The ESP32 tries to connect to MQTT continously but for some reason it doesn't succed. I'm pretty sure there's no problem on the broker side because if I use the pubsubclient I get succesful results:
|
This is a generic websocket filter class that has no knowledge of where the stream data is coming from or how to transmit into a stream. Actual I/O is delegated to the caller. The constructor receives optional buffer sizes, which sets the maximum frame length that can be generated by the implementation. However, there is no maximum frame length limit - the class allows streaming of the RX frame data in chunks. Websocket protocol negotiation is supported but chosen protocol is not (yet) enforced or reported.
Publicly exposed methods: - setWsEnabled(bool): toggle use of websockets before connect() - setWsUri(const char*): set URI endpoint where websocket is exposed (default "/") Tested with Eclipse Mosquitto served behind Apache 2.4 as websocket proxy.
Hello, I am trying to have my
I have also tried to modify the library enabling everything by hand but the same error follows. Sorry but I still don't get where I should define those, at the beginning of which file? |
Maybe take a look at https://github.com/bertmelis/espMqttClient, which is currently under development. |
Thank you @luebbe , I see that there is also an example of MQTT TLS for ESP32. If I manage to make that work I will write a guide and repost it because I have seen many posts where people cannot make the TLS work. |
according to @bertmelis, his library aims to be a plug-in replacemant for async-mqtt-client. The next time I change some of my esp code I'll use Bert's library instead. |
Thank you @luebbe! I really recommend to anyone that is trying to implement TLS for MQTT to start from here (especially for ESP32): |
This pull request adds support for establishing an encrypted TLS connection, if the underlying AsyncTCP library supports it and if the ASYNC_TCP_SSL_ENABLED is enabled, as used by several AsyncTCP forks implementing TLS. The TLS support simply forwards setting certificates and keys to the corresponding API calls in the underlying AsyncTCP client connection. Tested with my own reimplementation of the AsyncTCP API, AsyncTCPSock, but as the API is fully compatible with AsyncTCP TLS forks, it should work with them as well.