TLS increase timeout and fix crash (#23249)

This commit is contained in:
s-hadinger 2025-04-05 00:04:36 +02:00 committed by GitHub
parent 2bf67b96a6
commit e8baea464f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 4 deletions

View File

@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file.
### Fixed
- INA226 driver fixes (#23197)
- TLS increase timeout and fix crash
### Removed

View File

@ -303,7 +303,9 @@ int WiFiClientSecure_light::connect(IPAddress ip, uint16_t port, int32_t timeout
setLastError(ERR_TCP_CONNECT);
return 0;
}
return _connectSSL(_domain.isEmpty() ? nullptr : _domain.c_str());
bool success = _connectSSL(_domain.isEmpty() ? nullptr : _domain.c_str());
if (!success) { stop(); }
return success;
}
#else // ESP32
int WiFiClientSecure_light::connect(IPAddress ip, uint16_t port) {
@ -313,7 +315,9 @@ int WiFiClientSecure_light::connect(IPAddress ip, uint16_t port) {
setLastError(ERR_TCP_CONNECT);
return 0;
}
return _connectSSL(_domain.isEmpty() ? nullptr : _domain.c_str());
bool success = _connectSSL(_domain.isEmpty() ? nullptr : _domain.c_str());
if (!success) { stop(); }
return success;
}
#endif
@ -570,6 +574,7 @@ int WiFiClientSecure_light::_run_until(unsigned target, bool blocking) {
if (((int32_t)(millis() - (t + this->_loopTimeout)) >= 0)){
DEBUG_BSSL("_run_until: Timeout\n");
setLastError(ERR_TLS_TIMEOUT);
return -1;
}

View File

@ -137,7 +137,7 @@ class WiFiClientSecure_light : public WiFiClient {
}
private:
uint32_t _loopTimeout=5000;
uint32_t _loopTimeout=10000;
void _clear();
bool _ctx_present;
std::shared_ptr<br_ssl_client_context> _sc;
@ -192,7 +192,8 @@ class WiFiClientSecure_light : public WiFiClient {
#define ERR_CANT_RESOLVE_IP -1001
#define ERR_TCP_CONNECT -1002
// #define ERR_MISSING_EC_KEY -1003 // deprecated, AWS IoT is not called if the private key is not present
#define ERR_MISSING_CA -1004
// #define ERR_MISSING_CA -1004 // deprecated
#define ERR_TLS_TIMEOUT -1005
// For reference, BearSSL error codes:
// #define BR_ERR_OK 0