mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-12 01:53:07 +03:00
Add SSL Session capability to speed reconnections (#5160)
SSL Sessions enable most of the SSL handshake to be skipped when both client and server agree to use them. Add a BearSSLSession class and an optional setting to the SSL client to enable this. Note that SSL sessions are unrelated to HTTP sessions. They are ephemeral and only relate to the SSL parameters, not anything at the HTTP protocol level.
This commit is contained in:
committed by
GitHub
parent
8e11836378
commit
6314093fe5
@ -72,6 +72,7 @@ void WiFiClientSecure::_clear() {
|
||||
_recvapp_len = 0;
|
||||
_oom_err = false;
|
||||
_deleteChainKeyTA = false;
|
||||
_session = nullptr;
|
||||
_cipher_list = NULL;
|
||||
_cipher_cnt = 0;
|
||||
}
|
||||
@ -177,8 +178,11 @@ void WiFiClientSecure::setBufferSizes(int recv, int xmit) {
|
||||
|
||||
bool WiFiClientSecure::stop(unsigned int maxWaitMs) {
|
||||
bool ret = WiFiClient::stop(maxWaitMs); // calls our virtual flush()
|
||||
// Only if we've already connected, clear the connection options
|
||||
// Only if we've already connected, store session params and clear the connection options
|
||||
if (_handshake_done) {
|
||||
if (_session) {
|
||||
br_ssl_engine_get_session_parameters(_eng, _session->getSession());
|
||||
}
|
||||
_clearAuthenticationSettings();
|
||||
}
|
||||
_freeSSL();
|
||||
@ -865,7 +869,12 @@ bool WiFiClientSecure::_connectSSL(const char* hostName) {
|
||||
_cert_issuer_key_type, br_ec_get_default(), br_ecdsa_sign_asn1_get_default());
|
||||
}
|
||||
|
||||
if (!br_ssl_client_reset(_sc.get(), hostName, 0)) {
|
||||
// Restore session from the storage spot, if present
|
||||
if (_session) {
|
||||
br_ssl_engine_set_session_parameters(_eng, _session->getSession());
|
||||
}
|
||||
|
||||
if (!br_ssl_client_reset(_sc.get(), hostName, _session?1:0)) {
|
||||
_freeSSL();
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user