summaryrefslogtreecommitdiffstats
path: root/Source/cmCurl.cxx
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2022-09-13 21:03:45 (GMT)
committerBrad King <brad.king@kitware.com>2022-09-16 13:40:28 (GMT)
commit10bf34a2d97c600c3d806309c79137afba113cf9 (patch)
treea0ca663dec040d04ec00edd50d6eaab1dd81c79c /Source/cmCurl.cxx
parent355b12af792441cc3f9a561733b1cacc789f9719 (diff)
downloadCMake-10bf34a2d97c600c3d806309c79137afba113cf9.zip
CMake-10bf34a2d97c600c3d806309c79137afba113cf9.tar.gz
CMake-10bf34a2d97c600c3d806309c79137afba113cf9.tar.bz2
cmCurl: Honor OpenSSL certificate environment variables
Honor the OpenSSL environment variables used to specify the location of the TLS certificates, as specified in the `curl(1)` man page. Co-authored-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'Source/cmCurl.cxx')
-rw-r--r--Source/cmCurl.cxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/Source/cmCurl.cxx b/Source/cmCurl.cxx
index 28ee24d..fd6aee1 100644
--- a/Source/cmCurl.cxx
+++ b/Source/cmCurl.cxx
@@ -34,10 +34,21 @@
std::string cmCurlSetCAInfo(::CURL* curl, const std::string& cafile)
{
std::string e;
+ std::string env_ca;
if (!cafile.empty()) {
::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_CAINFO, cafile.c_str());
check_curl_result(res, "Unable to set TLS/SSL Verify CAINFO: ");
}
+ /* Honor the user-configurable OpenSSL environment variables. */
+ else if (cmSystemTools::GetEnv("SSL_CERT_FILE", env_ca) &&
+ cmSystemTools::FileExists(env_ca, true)) {
+ ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_CAINFO, env_ca.c_str());
+ check_curl_result(res, "Unable to set TLS/SSL Verify CAINFO: ");
+ } else if (cmSystemTools::GetEnv("SSL_CERT_DIR", env_ca) &&
+ cmSystemTools::FileIsDirectory(env_ca)) {
+ ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_CAPATH, env_ca.c_str());
+ check_curl_result(res, "Unable to set TLS/SSL Verify CAINFO: ");
+ }
#ifdef CMAKE_FIND_CAFILE
# define CMAKE_CAFILE_FEDORA "/etc/pki/tls/certs/ca-bundle.crt"
else if (cmSystemTools::FileExists(CMAKE_CAFILE_FEDORA, true)) {