mirror of
https://github.com/curl/curl.git
synced 2026-07-26 12:37:16 +03:00
lib: TLS session ticket caching reworked
Described in detail in internal doc TLS-SESSIONS.md Main points: - use a new `ssl_peer_key` for cache lookups by connection filters - recognize differences between TLSv1.3 and other tickets * TLSv1.3 tickets are single-use, cache can hold several of them for a peer * TLSv1.2 are reused, keep only a single one per peer - differentiate between ticket BLOB to store (that could be persisted) and object instances - use put/take/return pattern for cache access - remember TLS version, ALPN protocol, time received and lifetime of ticket - auto-expire tickets after their lifetime Closes #15774
This commit is contained in:
parent
e5e2e09a75
commit
fa0ccd9f1f
36 changed files with 1784 additions and 780 deletions
22
lib/share.c
22
lib/share.c
|
|
@ -30,6 +30,7 @@
|
|||
#include "share.h"
|
||||
#include "psl.h"
|
||||
#include "vtls/vtls.h"
|
||||
#include "vtls/vtls_scache.h"
|
||||
#include "hsts.h"
|
||||
#include "url.h"
|
||||
|
||||
|
|
@ -108,12 +109,8 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
|
|||
|
||||
case CURL_LOCK_DATA_SSL_SESSION:
|
||||
#ifdef USE_SSL
|
||||
if(!share->sslsession) {
|
||||
share->max_ssl_sessions = 8;
|
||||
share->sslsession = calloc(share->max_ssl_sessions,
|
||||
sizeof(struct Curl_ssl_session));
|
||||
share->sessionage = 0;
|
||||
if(!share->sslsession)
|
||||
if(!share->ssl_scache) {
|
||||
if(Curl_ssl_scache_create(8, 2, &share->ssl_scache))
|
||||
res = CURLSHE_NOMEM;
|
||||
}
|
||||
#else
|
||||
|
|
@ -174,7 +171,10 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
|
|||
|
||||
case CURL_LOCK_DATA_SSL_SESSION:
|
||||
#ifdef USE_SSL
|
||||
Curl_safefree(share->sslsession);
|
||||
if(share->ssl_scache) {
|
||||
Curl_ssl_scache_destroy(share->ssl_scache);
|
||||
share->ssl_scache = NULL;
|
||||
}
|
||||
#else
|
||||
res = CURLSHE_NOT_BUILT_IN;
|
||||
#endif
|
||||
|
|
@ -245,11 +245,9 @@ curl_share_cleanup(CURLSH *sh)
|
|||
#endif
|
||||
|
||||
#ifdef USE_SSL
|
||||
if(share->sslsession) {
|
||||
size_t i;
|
||||
for(i = 0; i < share->max_ssl_sessions; i++)
|
||||
Curl_ssl_kill_session(&(share->sslsession[i]));
|
||||
free(share->sslsession);
|
||||
if(share->ssl_scache) {
|
||||
Curl_ssl_scache_destroy(share->ssl_scache);
|
||||
share->ssl_scache = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue