Skip to content

Commit 2bf8bb0

Browse files
dschoGit for Windows Build Agent
authored andcommitted
http: when using Secure Channel, ignore sslCAInfo by default
As of cURL v7.60.0, the Secure Channel backend can use the certificate bundle provided via `http.sslCAInfo`, but that would override the Windows Certificate Store. Since this is not desirable by default, let's tell Git to not ask cURL to use that bundle by default when the `schannel` backend was configured via `http.sslBackend`, unless `http.schannelUseSSLCAInfo` overrides this behavior. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent c8b1449 commit 2bf8bb0

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Documentation/config.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2249,6 +2249,14 @@ http.schannelCheckRevoke::
22492249
certificate. This option is ignored if cURL lacks support for
22502250
setting the relevant SSL option at runtime.
22512251

2252+
http.schannelUseSSLCAInfo::
2253+
As of cURL v7.60.0, the Secure Channel backend can use the
2254+
certificate bundle provided via `http.sslCAInfo`, but that would
2255+
override the Windows Certificate Store. Since this is not desirable
2256+
by default, Git will tell cURL not to use that bundle by default
2257+
when the `schannel` backend was configured via `http.sslBackend`,
2258+
unless `http.schannelUseSSLCAInfo` overrides this behavior.
2259+
22522260
http.pinnedpubkey::
22532261
Public key of the https service. It may either be the filename of
22542262
a PEM or DER encoded public key file or a string starting with

http.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ static char *cached_accept_language;
158158
static char *http_ssl_backend;
159159

160160
static int http_schannel_check_revoke = 1;
161+
/*
162+
* With the backend being set to `schannel`, setting sslCAinfo would override
163+
* the Certificate Store in cURL v7.60.0 and later, which is not what we want
164+
* by default.
165+
*/
166+
static int http_schannel_use_ssl_cainfo;
161167

162168
size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
163169
{
@@ -317,6 +323,11 @@ static int http_options(const char *var, const char *value, void *cb)
317323
return 0;
318324
}
319325

326+
if (!strcmp("http.schannelusesslcainfo", var)) {
327+
http_schannel_use_ssl_cainfo = git_config_bool(var, value);
328+
return 0;
329+
}
330+
320331
if (!strcmp("http.minsessions", var)) {
321332
min_curl_sessions = git_config_int(var, value);
322333
#ifndef USE_CURL_MULTI
@@ -869,7 +880,13 @@ static CURL *get_curl_handle(void)
869880
if (ssl_pinnedkey != NULL)
870881
curl_easy_setopt(result, CURLOPT_PINNEDPUBLICKEY, ssl_pinnedkey);
871882
#endif
872-
if (ssl_cainfo != NULL)
883+
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend) &&
884+
!http_schannel_use_ssl_cainfo) {
885+
curl_easy_setopt(result, CURLOPT_CAINFO, NULL);
886+
#if LIBCURL_VERSION_NUM >= 0x073400
887+
curl_easy_setopt(result, CURLOPT_PROXY_CAINFO, NULL);
888+
#endif
889+
} else if (ssl_cainfo != NULL)
873890
curl_easy_setopt(result, CURLOPT_CAINFO, ssl_cainfo);
874891

875892
if (curl_low_speed_limit > 0 && curl_low_speed_time > 0) {

0 commit comments

Comments
 (0)