-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
HTTPUpdateServer with TLS not working with WiFiClientSecure #4638
Comments
I attach an example using only WiFiClientSecure giving the same behaviour. However, if WiFiClientSecure is statically declared in setup(), so that it destructs when setup returns, the update works.
|
OK, I narrowed it down and found a solution. But I still consider this a bug. Below is another sketch, this time a modification of the original using the heap for MQTTClient and WiFiClientSecure. Before starting the update server I delete these objects, and the upload succeeds. The difference from my first attempt at using the heap is that was still statically declaring WiFiClientSecure. This is a sufficient workaround for my use case, but why is this happening?
|
BearSSL is merged in #4273 , with alternate BearSSL::WiFi* classes. Although axtls-based classes are still available and even the default, they are planned for deprecation and then retirement, hence won't be fixed. Any issues with BearSSL-based classes should be reported in new issues. |
Basic Infos
Platform
Settings in IDE
Problem Description
I am using ESP8266HTTPUpdateServer over TLS together with an MQTT client (https://github.com/256dpi/arduino-mqtt) also using TLS for secure OTA updates. The basic idea is to publish an MQTT message putting the ESP into firmware update mode, which starts the update server (WebServerSecure on port 443 with a TLS certificate).
The update works fine as long as there is no MQTT client class (WiFiClientSecure) connected. It also works if HTTPUpdateServer uses an insecure HTTP webserver instead of the TLS enabled equivalent WebServerSecure.
The failure happens when the firmware is uploaded (clicking the upload button). This means the update server can serve a TLS encrypted upload form, but as soon as I click upload with a new .bin file, it goes into a loop of TLS handshaking, and never starts the upload. The normal serial message of "sleep disabled" and then the series of upload dots "." are not printed.
I have tried a bit of debugging, and it seems that _currentClientSecure.available() under the case HC_WAIT_READ is never returning a nonzero number (ESP8266WebServerSecure.cpp:103 master branch). My suspicion is that somehow the WiFiClientSecure is somehow interfering with the client in WebServerSecure.
If I comment out the mqttconnect() block in the loop() of the sketch below, everything works fine. Note that even if I call mqttclient.disconnect() before starting the server, the upload still does not work. It is something about the initially connected instantiation of the WiFiClientSecure class inside of MQTTClient.
Also note I have tried dynamically instantiating MQTTClient and deleting it before starting the update server in case it had to do with a memory issue, but the upload fails also in this case.
MCVE Sketch
Debug Messages
Serial output (DEBUG_ESP_HTTP_SERVER defined, each
New secure client
is a successful TLS handshake but nothing received after that):The text was updated successfully, but these errors were encountered: