Skip to content

Commit ce6df21

Browse files
committed
Fix flush issue.
1 parent 8298ebc commit ce6df21

File tree

7 files changed

+37
-36
lines changed

7 files changed

+37
-36
lines changed

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ESP_SSLClient",
3-
"version": "2.1.2",
3+
"version": "2.1.3",
44
"keywords": "communication, REST, esp32, esp8266, arduino",
55
"description": "This library provided the Secure Layer Networking (SSL/TLS) TCP Client for ESP8266, ESP32 and Raspberry Pi RP2040, Teensy, SAMD, AVR and other Arduino devices (except for avr) that support external networking interfaces e.g., WiFiClient, EthernetClient and GSMClient.",
66
"repository": {

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name=ESP_SSLClient
22

3-
version=2.1.2
3+
version=2.1.3
44

55
author=Mobizt
66

src/ESP_SSLClient.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
*
3-
* The ESP SSL Client Class, ESP_SSLClient.h v2.1.2
3+
* The ESP SSL Client Class, ESP_SSLClient.h v2.1.3
44
*
5-
* Created August 11, 2023
5+
* Created August 13, 2023
66
*
77
* The MIT License (MIT)
88
* Copyright (c) 2023 K. Suwatchai (Mobizt)
@@ -44,7 +44,7 @@ class ESP_SSLClient
4444
{
4545
public:
4646
ESP_SSLClient(){};
47-
virtual ~ESP_SSLClient(){};
47+
~ESP_SSLClient(){};
4848
};
4949

5050
#endif

src/client/BSSL_SSL_Client.cpp

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* BSSL_SSL_Client library v1.0.8 for Arduino devices.
2+
* BSSL_SSL_Client library v1.0.9 for Arduino devices.
33
*
4-
* Created August 11, 2003
4+
* Created August 13, 2003
55
*
66
* This work contains codes based on WiFiClientSecure from Earle F. Philhower and SSLClient from OSU OPEnS Lab.
77
*
@@ -180,6 +180,7 @@ uint8_t BSSL_SSL_Client::connected()
180180
}
181181

182182
// set the write error so the engine doesn't try to close the connection
183+
_is_connected = false;
183184
stop();
184185
}
185186
else if (!wr_ok)
@@ -444,34 +445,30 @@ int BSSL_SSL_Client::connectSSL(const char *host, uint16_t port)
444445

445446
void BSSL_SSL_Client::stop()
446447
{
447-
448-
if (!_is_connected)
448+
if (!_secure)
449449
return;
450450

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());
456454

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();
471468
}
472469

473470
// close the socket
474-
if (_basic_client && _basic_client->connected())
471+
if (_basic_client)
475472
{
476473
_basic_client->flush();
477474
_basic_client->stop();

src/client/BSSL_SSL_Client.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* BSSL_SSL_Client library v1.0.8 for Arduino devices.
2+
* BSSL_SSL_Client library v1.0.9 for Arduino devices.
33
*
4-
* Created August 11, 2003
4+
* Created August 13, 2003
55
*
66
* This work contains codes based on WiFiClientSecure from Earle F. Philhower and SSLClient from OSU OPEnS Lab.
77
*

src/client/BSSL_TCP_Client.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* BSSL_TCP_Client v2.0.9 for Arduino devices.
2+
* BSSL_TCP_Client v2.0.10 for Arduino devices.
33
*
4-
* Created August 11, 2023
4+
* Created August 13, 2023
55
*
66
* The MIT License (MIT)
77
* Copyright (c) 2023 K. Suwatchai (Mobizt)
@@ -272,7 +272,11 @@ void BSSL_TCP_Client::setHandshakeTimeout(unsigned long handshake_timeout)
272272

273273
void BSSL_TCP_Client::flush()
274274
{
275-
_ssl_client.flush();
275+
if (!_basic_client)
276+
return;
277+
278+
while (available() > 0)
279+
read();
276280
}
277281

278282
void BSSL_TCP_Client::setBufferSizes(int recv, int xmit)

src/client/BSSL_TCP_Client.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* BSSL_TCP_Client v2.0.9 for Arduino devices.
2+
* BSSL_TCP_Client v2.0.10 for Arduino devices.
33
*
4-
* Created August 11, 2023
4+
* Created August 13, 2023
55
*
66
* The MIT License (MIT)
77
* Copyright (c) 2023 K. Suwatchai (Mobizt)

0 commit comments

Comments
 (0)