diff options
-rw-r--r-- | Help/envvar/CMAKE_TLS_VERSION.rst | 12 | ||||
-rw-r--r-- | Help/manual/cmake-env-variables.7.rst | 1 | ||||
-rw-r--r-- | Help/release/dev/curl-tls-version.rst | 7 | ||||
-rw-r--r-- | Help/variable/CMAKE_TLS_VERSION.rst | 2 | ||||
-rw-r--r-- | Source/cmFileCommand.cxx | 12 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/TLS_VERSION-bad-stderr.txt | 5 | ||||
-rw-r--r-- | Tests/RunCMake/file-DOWNLOAD/TLS_VERSION-bad.cmake | 5 |
7 files changed, 41 insertions, 3 deletions
diff --git a/Help/envvar/CMAKE_TLS_VERSION.rst b/Help/envvar/CMAKE_TLS_VERSION.rst new file mode 100644 index 0000000..3bb2c97 --- /dev/null +++ b/Help/envvar/CMAKE_TLS_VERSION.rst @@ -0,0 +1,12 @@ +CMAKE_TLS_VERSION +----------------- + +.. versionadded:: 3.30 + +.. include:: ENV_VAR.txt + +Specify the default value for the :command:`file(DOWNLOAD)` and +:command:`file(UPLOAD)` commands' ``TLS_VERSION`` option. +This environment variable is used if the option is not given +and the :variable:`CMAKE_TLS_VERSION` cmake variable is not set. +See that variable for allowed values. diff --git a/Help/manual/cmake-env-variables.7.rst b/Help/manual/cmake-env-variables.7.rst index 3ab5935..5273194 100644 --- a/Help/manual/cmake-env-variables.7.rst +++ b/Help/manual/cmake-env-variables.7.rst @@ -27,6 +27,7 @@ Environment Variables that Change Behavior /envvar/CMAKE_MAXIMUM_RECURSION_DEPTH /envvar/CMAKE_PREFIX_PATH /envvar/CMAKE_PROGRAM_PATH + /envvar/CMAKE_TLS_VERSION /envvar/SSL_CERT_DIR /envvar/SSL_CERT_FILE diff --git a/Help/release/dev/curl-tls-version.rst b/Help/release/dev/curl-tls-version.rst index fcc0648..999e20c 100644 --- a/Help/release/dev/curl-tls-version.rst +++ b/Help/release/dev/curl-tls-version.rst @@ -5,6 +5,7 @@ curl-tls-version gained a ``TLS_VERSION <min>`` option to specify the minimum TLS version for connections to ``https://`` URLs. -* The :variable:`CMAKE_TLS_VERSION` variable was added to specify a - default minimum TLS version for connections to ``https://`` URLs by - the :command:`file(DOWNLOAD)` and :command:`file(UPLOAD)` commands. +* The :variable:`CMAKE_TLS_VERSION` variable and :envvar:`CMAKE_TLS_VERSION` + environment variable were added to specify a default minimum TLS version + for connections to ``https://`` URLs by the :command:`file(DOWNLOAD)` + and :command:`file(UPLOAD)` commands. diff --git a/Help/variable/CMAKE_TLS_VERSION.rst b/Help/variable/CMAKE_TLS_VERSION.rst index fd790b3..e4d9e7b 100644 --- a/Help/variable/CMAKE_TLS_VERSION.rst +++ b/Help/variable/CMAKE_TLS_VERSION.rst @@ -5,6 +5,8 @@ CMAKE_TLS_VERSION Specify the default value for the :command:`file(DOWNLOAD)` and :command:`file(UPLOAD)` commands' ``TLS_VERSION`` option. +If this variable is not set, the commands check the +:envvar:`CMAKE_TLS_VERSION` environment variable. The value may be one of: diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index d193375..a0282f6 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2030,6 +2030,12 @@ bool HandleDownloadCommand(std::vector<std::string> const& args, tls_version = *v; } } + if (!tls_version) { + if (cm::optional<std::string> v = + cmSystemTools::GetEnvVar("CMAKE_TLS_VERSION")) { + tls_version = std::move(v); + } + } // Can't calculate hash if we don't save the file. // TODO Incrementally calculate hash in the write callback as the file is @@ -2421,6 +2427,12 @@ bool HandleUploadCommand(std::vector<std::string> const& args, tls_version = *v; } } + if (!tls_version) { + if (cm::optional<std::string> v = + cmSystemTools::GetEnvVar("CMAKE_TLS_VERSION")) { + tls_version = std::move(v); + } + } // Open file for reading: // diff --git a/Tests/RunCMake/file-DOWNLOAD/TLS_VERSION-bad-stderr.txt b/Tests/RunCMake/file-DOWNLOAD/TLS_VERSION-bad-stderr.txt index e2ed989..421c8cf 100644 --- a/Tests/RunCMake/file-DOWNLOAD/TLS_VERSION-bad-stderr.txt +++ b/Tests/RunCMake/file-DOWNLOAD/TLS_VERSION-bad-stderr.txt @@ -1,4 +1,9 @@ ^CMake Error at TLS_VERSION-bad\.cmake:[0-9]+ \(file\): + file DOWNLOAD given unknown TLS/SSL version bad-env +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Error at TLS_VERSION-bad\.cmake:[0-9]+ \(file\): file DOWNLOAD given unknown TLS/SSL version bad-var Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/file-DOWNLOAD/TLS_VERSION-bad.cmake b/Tests/RunCMake/file-DOWNLOAD/TLS_VERSION-bad.cmake index 74c01a3..51ae4a2 100644 --- a/Tests/RunCMake/file-DOWNLOAD/TLS_VERSION-bad.cmake +++ b/Tests/RunCMake/file-DOWNLOAD/TLS_VERSION-bad.cmake @@ -1,3 +1,8 @@ +# The environment variable provides a default. +set(ENV{CMAKE_TLS_VERSION} bad-env) +file(DOWNLOAD "" TLS_VERIFY 1 STATUS status LOG log) + +# The cmake variable overrides the environment variable. set(CMAKE_TLS_VERSION bad-var) file(DOWNLOAD "" TLS_VERIFY 1 STATUS status LOG log) |