Honour certificate-related environment variables used by curl

Use the same environment variables that curl uses to customize the
location of the trusted certificates when using libcurl.

This is useful when using libcurl under Windows (where there is no
reasonable default) but also under Linux where a custom-built libcurl
may refer to a file or directory not available on the target system.
This commit is contained in:
Vadim Zeitlin
2025-04-18 15:45:52 +02:00
parent 715b0e8fd3
commit f4eb05d78e
2 changed files with 19 additions and 0 deletions
+3
View File
@@ -15,6 +15,9 @@
(e.g. HTTP/2, TLS 1.3).
System-wide configuration like proxy and SSL certificates will be used
when possible.
When using libcurl backend, environment variables `CURL_CA_BUNDLE`,
`SSL_CERT_FILE` and `SSL_CERT_DIR` are used to change the trusted
certificates location if they are defined.
Instances of wxWebRequest are created by using
wxWebSession::CreateRequest().
+16
View File
@@ -169,6 +169,22 @@ CURL* wxCURLEasyInit()
return nullptr;
}
// Honour the same environment variables that curl tool itself uses for
// customizing the certificates locations.
wxString path;
if ( wxGetEnv("CURL_CA_BUNDLE", &path) )
{
wxCURLSetOpt(handle, CURLOPT_CAINFO, path);
}
else // CURL_CA_BUNDLE overrides SSL_CERT_XXX
{
if ( wxGetEnv("SSL_CERT_DIR", &path) )
wxCURLSetOpt(handle, CURLOPT_CAPATH, path);
if ( wxGetEnv("SSL_CERT_FILE", &path) )
wxCURLSetOpt(handle, CURLOPT_CAINFO, path);
}
return handle;
}