Repository navigation
Conversation
|
this looks like a valid fix, but should be fixed upstream in the owner's project at https://github.com/bertmelis/espMqttClient . Please do a PR there. |
|
Thanks for looking. I don't think espMqttClient can take this one: its |
|
Raised at mobizt/ESP_SSLClient#35. With that change alone, without the workaround here, the socket is closed straight away after a failed handshake as well. |
|
mobizt/ESP_SSLClient#35 is merged (aa7fb64) but isn't in a release yet, the latest is still 3.1.3. Three options:
The workaround is harmless alongside the fixed library (stopping an already stopped |
ESP_SSLClient::stop() returns early if the session never became secure, so after a failed handshake (e.g. certificate check before NTP sync or a host name mismatch) the TCP socket stayed open and the client waited in disconnectingTcp2 until the broker closed it. Stop the socket as well.
4982c34 to
82db41a
Compare
Problem
ESP_SSLClient::stop()returns early when the session never became secure. After a failed TLS handshake (a certificate check before NTP has synced, a host name mismatch, a CA that doesn't match) the underlying TCP socket therefore stays open, and espMqttClient sits indisconnectingTcp2until the server closes the connection. Only then can it retry. A server that is still waiting for the client's half of the handshake may never close it, and then MQTT stays down.Fix
ClientSecureSync::stop()also stops the plainWiFiClientunderneath, so a failed handshake releases the socket straight away.Testing
A TLS server EMS-ESP can't validate:
openssl s_serverwith a P-521 certificate, while EMS-ESP has the Let's Encrypt ISRG Root X2 CA configured. The handshake gets as far as the server's certificate, then fails validation. Packets captured on the server:s_16M_P, clang-format clean.Related MQTT TLS fixes, independent of each other: #3301 (task stack), #3302 (TLS on any port), #3303 (receive buffer).
Checklist
devbranch.clang-formatCHANGELOG_LATEST.mdupdated