url: connection reuse fixes for starttls

Add test_31_13 to check connection reuse on mixed --ssl-reqd setting.
For that add debug env var CURL_DBG_NO_USE_SSL_ON_FIRST to disable
--ssl-reqd for the first url. Check that the connection without SSL
from the first url is not reused on the second URL that requires it.

Tweak special ftp: protocol check to fail a DEBUGASSERT on mismatched
`use_ssl` settings as that should have been caught before in the
connection reuse matching (imap/smtp etc. do not have this extra check
and rely on the general part doing its job).

Closes #21665
This commit is contained in:
Stefan Eissing 2026-05-19 10:57:53 +02:00 committed by Daniel Stenberg
parent f1a6f190a6
commit 4ff212f8ed
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
5 changed files with 55 additions and 14 deletions

View file

@ -951,6 +951,13 @@ CURLcode config2setopts(struct OperationConfig *config,
result = ssl_setopts(config, curl);
if(setopt_bad(result))
return result;
#ifdef DEBUGBUILD
if(!per->urlnum) {
char *env = getenv("CURL_DBG_NO_USE_SSL_ON_FIRST");
if(env)
my_setopt_enum(curl, CURLOPT_USE_SSL, CURLUSESSL_NONE);
}
#endif
}
if(config->path_as_is)