|
1 | 1 | /** |
2 | | - * BSSL_SSL_Client library v1.0.8 for Arduino devices. |
| 2 | + * BSSL_SSL_Client library v1.0.9 for Arduino devices. |
3 | 3 | * |
4 | | - * Created August 11, 2003 |
| 4 | + * Created August 13, 2003 |
5 | 5 | * |
6 | 6 | * This work contains codes based on WiFiClientSecure from Earle F. Philhower and SSLClient from OSU OPEnS Lab. |
7 | 7 | * |
@@ -180,6 +180,7 @@ uint8_t BSSL_SSL_Client::connected() |
180 | 180 | } |
181 | 181 |
|
182 | 182 | // set the write error so the engine doesn't try to close the connection |
| 183 | + _is_connected = false; |
183 | 184 | stop(); |
184 | 185 | } |
185 | 186 | else if (!wr_ok) |
@@ -444,34 +445,30 @@ int BSSL_SSL_Client::connectSSL(const char *host, uint16_t port) |
444 | 445 |
|
445 | 446 | void BSSL_SSL_Client::stop() |
446 | 447 | { |
447 | | - |
448 | | - if (!_is_connected) |
| 448 | + if (!_secure) |
449 | 449 | return; |
450 | 450 |
|
451 | | - if (_secure) |
452 | | - { |
453 | | - // Only if we've already connected, store session params and clear the connection options |
454 | | - if (_session) |
455 | | - br_ssl_engine_get_session_parameters(_eng, _session->getSession()); |
| 451 | + // Only if we've already connected, store session params and clear the connection options |
| 452 | + if (_session) |
| 453 | + br_ssl_engine_get_session_parameters(_eng, _session->getSession()); |
456 | 454 |
|
457 | | - // tell the SSL connection to gracefully close |
458 | | - // Disabled to prevent close_notify from hanging BSSL_SSL_Client |
459 | | - // br_ssl_engine_close(_eng); |
460 | | - // if the engine isn't closed, and the socket is still open |
461 | | - auto state = br_ssl_engine_current_state(_eng); |
462 | | - if (state != BR_SSL_CLOSED && state != 0 && connected()) |
463 | | - { |
464 | | - // Discard any incoming application data. |
465 | | - _recvapp_buf = br_ssl_engine_recvapp_buf(_eng, &_recvapp_len); |
466 | | - if (_recvapp_buf != nullptr) |
467 | | - br_ssl_engine_recvapp_ack(_eng, _recvapp_len); |
468 | | - // run SSL to finish any existing transactions |
469 | | - flush(); |
470 | | - } |
| 455 | + // tell the SSL connection to gracefully close |
| 456 | + // Disabled to prevent close_notify from hanging BSSL_SSL_Client |
| 457 | + // br_ssl_engine_close(_eng); |
| 458 | + // if the engine isn't closed, and the socket is still open |
| 459 | + auto state = br_ssl_engine_current_state(_eng); |
| 460 | + if (state != BR_SSL_CLOSED && state != 0 && connected()) |
| 461 | + { |
| 462 | + // Discard any incoming application data. |
| 463 | + _recvapp_buf = br_ssl_engine_recvapp_buf(_eng, &_recvapp_len); |
| 464 | + if (_recvapp_buf != nullptr) |
| 465 | + br_ssl_engine_recvapp_ack(_eng, _recvapp_len); |
| 466 | + // run SSL to finish any existing transactions |
| 467 | + flush(); |
471 | 468 | } |
472 | 469 |
|
473 | 470 | // close the socket |
474 | | - if (_basic_client && _basic_client->connected()) |
| 471 | + if (_basic_client) |
475 | 472 | { |
476 | 473 | _basic_client->flush(); |
477 | 474 | _basic_client->stop(); |
|
0 commit comments