mirror of
https://github.com/curl/curl.git
synced 2026-08-26 22:34:45 +03:00
OpenSSL: check reuse of sessions for verify status
OpenSSL records its peer verification status inside its SSL_SESSION objects. When a session is later reused, the SSL connection inherits this verify status. Session keys prevent reuse of sessions between connections that verify the peer and those who do not. However, when Apple SecTrust is used to verify a connection, this does not update the Sessions verify status (and there is no setter). On session reuse, OpenSSL fails the verification and Apple SecTrust cannot verify either since the certificate peer chain is not available. Fix this by checking the verification status on session reuse and remove the session again if the peer needs to be verified, but the session is not. Reported-by: Christian Schmitza Fixes #20435 Closes #20446
This commit is contained in:
parent
af508e3641
commit
065b149df0
7 changed files with 73 additions and 37 deletions
|
|
@ -211,13 +211,13 @@ static int my_progress_d_cb(void *userdata,
|
|||
static int setup_hx_download(CURL *curl, const char *url, struct transfer_d *t,
|
||||
long http_version, struct curl_slist *host,
|
||||
CURLSH *share, int use_earlydata,
|
||||
int fresh_connect)
|
||||
int fresh_connect, char *cafile)
|
||||
{
|
||||
curl_easy_setopt(curl, CURLOPT_SHARE, share);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, http_version);
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
if(cafile)
|
||||
curl_easy_setopt(curl, CURLOPT_CAINFO, cafile);
|
||||
curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "");
|
||||
curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, (long)(128 * 1024));
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_write_d_cb);
|
||||
|
|
@ -292,11 +292,12 @@ static CURLcode test_cli_hx_download(const char *URL)
|
|||
size_t max_host_conns = 0;
|
||||
size_t max_total_conns = 0;
|
||||
int fresh_connect = 0;
|
||||
char *cafile = NULL;
|
||||
CURLcode result = CURLE_OK;
|
||||
|
||||
(void)URL;
|
||||
|
||||
while((ch = cgetopt(test_argc, test_argv, "aefhm:n:xA:F:M:P:r:T:V:"))
|
||||
while((ch = cgetopt(test_argc, test_argv, "aefhm:n:xA:C:F:M:P:r:T:V:"))
|
||||
!= -1) {
|
||||
const char *opt = coptarg;
|
||||
curl_off_t num;
|
||||
|
|
@ -329,6 +330,10 @@ static CURLcode test_cli_hx_download(const char *URL)
|
|||
if(!curlx_str_number(&opt, &num, LONG_MAX))
|
||||
abort_offset = (size_t)num;
|
||||
break;
|
||||
case 'C':
|
||||
curlx_free(cafile);
|
||||
cafile = curlx_strdup(coptarg);
|
||||
break;
|
||||
case 'F':
|
||||
if(!curlx_str_number(&opt, &num, LONG_MAX))
|
||||
fail_offset = (size_t)num;
|
||||
|
|
@ -432,7 +437,7 @@ static CURLcode test_cli_hx_download(const char *URL)
|
|||
t->curl = curl_easy_init();
|
||||
if(!t->curl ||
|
||||
setup_hx_download(t->curl, url, t, http_version, host, share,
|
||||
use_earlydata, fresh_connect)) {
|
||||
use_earlydata, fresh_connect, cafile)) {
|
||||
curl_mfprintf(stderr, "[t-%zu] FAILED setup\n", i);
|
||||
result = (CURLcode)1;
|
||||
goto cleanup;
|
||||
|
|
@ -515,7 +520,7 @@ static CURLcode test_cli_hx_download(const char *URL)
|
|||
t->curl = curl_easy_init();
|
||||
if(!t->curl ||
|
||||
setup_hx_download(t->curl, url, t, http_version, host, share,
|
||||
use_earlydata, fresh_connect)) {
|
||||
use_earlydata, fresh_connect, cafile)) {
|
||||
curl_mfprintf(stderr, "[t-%zu] FAILED setup\n", i);
|
||||
result = (CURLcode)1;
|
||||
goto cleanup;
|
||||
|
|
@ -566,6 +571,7 @@ cleanup:
|
|||
optcleanup:
|
||||
|
||||
curlx_free(resolve);
|
||||
curlx_free(cafile);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue