mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-08-18 01:19:45 +08:00
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:
@@ -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().
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user