1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

WiFiClientSecure: don’t send close alert when opening new session

When WiFiClientSecure::connect was called, it would first tear down and
existing and set up new TCP session, then tear down existing TLS session
(using ssl_free), and then set up a new one. This caused TLS close-
notify alert to be sent to the new TCP session, preventing new session
from being established. This change postpones setting IO ctx to the new
TCP connection, fixing this issue.

Ref https://github.com/esp8266/Arduino/issues/3330
This commit is contained in:
Ivan Grokhotkov 2017-06-05 17:30:57 +08:00
parent e39a46fe04
commit 8c3bb69530

View File

@ -93,10 +93,16 @@ public:
SSL_EXTENSIONS* ext = ssl_ext_new();
ssl_ext_set_host_name(ext, hostName);
ssl_ext_set_max_fragment_size(ext, 4096);
s_io_ctx = ctx;
if (_ssl) {
/* Creating a new TLS session on top of a new TCP connection.
ssl_free will want to send a close notify alert, but the old TCP connection
is already gone at this point, so reset s_io_ctx. */
s_io_ctx = nullptr;
ssl_free(_ssl);
_available = 0;
_read_ptr = nullptr;
}
s_io_ctx = ctx;
_ssl = ssl_client_new(_ssl_ctx, 0, nullptr, 0, ext);
uint32_t t = millis();