mirror of
https://github.com/Kitware/CMake.git
synced 2026-07-01 04:07:15 +00:00
file(DOWNLOAD/UPLOAD): Restore support for curl built without a TLS backend
Since commit 38390245a2 (ctest: Require minimum TLS 1.2 by default,
2024-09-23, v3.31.0-rc1~47^2), our TLS-1.2 default fails with a curl
built without any TLS backend, causing even `file://` and `http://`
URLs to fail. Teach CMake to recognize both ways libcurl may report
that it was built without TLS support.
Fixes: #27849
This commit is contained in:
committed by
Brad King
parent
389c58ffe3
commit
18d5daa7f3
@@ -2215,7 +2215,16 @@ bool HandleDownloadCommand(std::vector<std::string> const& args,
|
||||
if (tlsVersionOpt.has_value()) {
|
||||
if (cm::optional<int> v = cmCurlParseTLSVersion(*tlsVersionOpt)) {
|
||||
res = ::curl_easy_setopt(curl, CURLOPT_SSLVERSION, *v);
|
||||
if (tlsVersionDefaulted && res == CURLE_NOT_BUILT_IN) {
|
||||
// If the caller did not explicitly ask for TLS, and libcurl was
|
||||
// built without any TLS backend, ignore failure to set our default.
|
||||
// Note that libcurl reports the absence of any TLS backend with
|
||||
// one of two distinct errors depending on how it was built:
|
||||
// - CURLE_NOT_BUILT_IN from the Curl_setopt_SSLVERSION
|
||||
// stub macro in setopt.h, or
|
||||
// - CURLE_UNKNOWN_OPTION from the function-level #else
|
||||
// arm of setopt_long_ssl() in setopt.c.
|
||||
if (tlsVersionDefaulted &&
|
||||
(res == CURLE_NOT_BUILT_IN || res == CURLE_UNKNOWN_OPTION)) {
|
||||
res = CURLE_OK;
|
||||
}
|
||||
check_curl_result(res,
|
||||
@@ -2613,7 +2622,10 @@ bool HandleUploadCommand(std::vector<std::string> const& args,
|
||||
if (tlsVersionOpt.has_value()) {
|
||||
if (cm::optional<int> v = cmCurlParseTLSVersion(*tlsVersionOpt)) {
|
||||
res = ::curl_easy_setopt(curl, CURLOPT_SSLVERSION, *v);
|
||||
if (tlsVersionDefaulted && res == CURLE_NOT_BUILT_IN) {
|
||||
// See HandleDownloadCommand for the rationale behind accepting both
|
||||
// CURLE_NOT_BUILT_IN and CURLE_UNKNOWN_OPTION here.
|
||||
if (tlsVersionDefaulted &&
|
||||
(res == CURLE_NOT_BUILT_IN || res == CURLE_UNKNOWN_OPTION)) {
|
||||
res = CURLE_OK;
|
||||
}
|
||||
check_curl_result(
|
||||
|
||||
Reference in New Issue
Block a user