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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Oct 25, 2018 at 11:53 UTC
b67d40adbbaf4f5c4898001bf062a9fd67e43368
2 files changed
+26
-1
Documentation/config.txt
+8
@@ -2249,6 +2249,14 @@ http.schannelCheckRevoke::
2249
certificate. This option is ignored if cURL lacks support for
2250
setting the relevant SSL option at runtime.
2251
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
+
2260
http.pinnedpubkey::
2261
Public key of the https service. It may either be the filename of
2262
a PEM or DER encoded public key file or a string starting with
http.c
+18
-1
@@ -158,6 +158,12 @@ static char *cached_accept_language;
158
static char *http_ssl_backend;
159
160
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;
167
168
size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
169
{
@@ -317,6 +323,11 @@ static int http_options(const char *var, const char *value, void *cb)
323
return 0;
324
}
325
326
+ if (!strcmp("http.schannelusesslcainfo", var)) {
327
+ http_schannel_use_ssl_cainfo = git_config_bool(var, value);
328
+ return 0;
329
+ }
330
+
331
if (!strcmp("http.minsessions", var)) {
332
min_curl_sessions = git_config_int(var, value);
333
#ifndef USE_CURL_MULTI
@@ -869,7 +880,13 @@ static CURL *get_curl_handle(void)
880
if (ssl_pinnedkey != NULL)
881
curl_easy_setopt(result, CURLOPT_PINNEDPUBLICKEY, ssl_pinnedkey);
882
#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)
890
curl_easy_setopt(result, CURLOPT_CAINFO, ssl_cainfo);
891
892
if (curl_low_speed_limit > 0 && curl_low_speed_time > 0) {