git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 3/3] http: when using Secure Channel, ignore sslCAInfo by default

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 25, 2018, 18:53 UTC
Message-ID
<a5f937a36d454d6d99bb64d4be3c389cf996826a.1540493630.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.46.v2.git.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

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>
---
 Documentation/config.txt |  8 ++++++++
 http.c                   | 19 ++++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index d569ebd49..1f6a6a4a6 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1997,6 +1997,14 @@ http.schannelCheckRevoke::
 	certificate. This option is ignored if cURL lacks support for
 	setting the relevant SSL option at runtime.
 
+http.schannelUseSSLCAInfo::
+	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, Git will tell cURL not to use that bundle by default
+	when the `schannel` backend was configured via `http.sslBackend`,
+	unless `http.schannelUseSSLCAInfo` overrides this behavior.
+
 http.pinnedpubkey::
 	Public key of the https service. It may either be the filename of
 	a PEM or DER encoded public key file or a string starting with
diff --git a/http.c b/http.c
index 65daa9bfa..28009ca73 100644
--- a/http.c
+++ b/http.c
@@ -158,6 +158,12 @@ static char *cached_accept_language;
 static char *http_ssl_backend;
 
 static int http_schannel_check_revoke = 1;
+/*
+ * With the backend being set to `schannel`, setting sslCAinfo would override
+ * the Certificate Store in cURL v7.60.0 and later, which is not what we want
+ * by default.
+ */
+static int http_schannel_use_ssl_cainfo;
 
 size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
 {
@@ -317,6 +323,11 @@ static int http_options(const char *var, const char *value, void *cb)
 		return 0;
 	}
 
+	if (!strcmp("http.schannelusesslcainfo", var)) {
+		http_schannel_use_ssl_cainfo = git_config_bool(var, value);
+		return 0;
+	}
+
 	if (!strcmp("http.minsessions", var)) {
 		min_curl_sessions = git_config_int(var, value);
 #ifndef USE_CURL_MULTI
@@ -869,7 +880,13 @@ static CURL *get_curl_handle(void)
 	if (ssl_pinnedkey != NULL)
 		curl_easy_setopt(result, CURLOPT_PINNEDPUBLICKEY, ssl_pinnedkey);
 #endif
-	if (ssl_cainfo != NULL)
+	if (http_ssl_backend && !strcmp("schannel", http_ssl_backend) &&
+	    !http_schannel_use_ssl_cainfo) {
+		curl_easy_setopt(result, CURLOPT_CAINFO, NULL);
+#if LIBCURL_VERSION_NUM >= 0x073400
+		curl_easy_setopt(result, CURLOPT_PROXY_CAINFO, NULL);
+#endif
+	} else if (ssl_cainfo != NULL)
 		curl_easy_setopt(result, CURLOPT_CAINFO, ssl_cainfo);
 
 	if (curl_low_speed_limit > 0 && curl_low_speed_time > 0) {
-- 
gitgitgadget
Previous: Brendan Forster via GitGitGadget
Message 28 of 28 in “Allow choosing the SSL backend cURL uses (plus related patches)”
  1. 0/3 Allow choosing the SSL backend cURL uses (plus related patches)Johannes Schindelin via GitGitGadget, Oct 15, 2018
  2. 1/3 http: add support for selecting SSL backends at runtimeJohannes Schindelin via GitGitGadget, Oct 15, 2018
  3. Eric SunshineOct 15, 2018
  4. 2/3 http: add support for disabling SSL revocation checks in cURLBrendan Forster via GitGitGadget, Oct 15, 2018
  5. Eric SunshineOct 15, 2018
  6. Johannes SchindelinOct 16, 2018
  7. Junio C HamanoOct 25, 2018
  8. http: give curl version warnings consistentlyJunio C Hamano, Oct 25, 2018
  9. Jeff KingOct 25, 2018
  10. Johannes SchindelinOct 25, 2018
  11. Junio C HamanoOct 26, 2018
  12. Johannes SchindelinOct 25, 2018
  13. Junio C HamanoOct 16, 2018
  14. Jeff KingOct 16, 2018
  15. Johannes SchindelinOct 16, 2018
  16. Jeff KingOct 16, 2018
  17. Johannes SchindelinOct 16, 2018
  18. Junio C HamanoOct 18, 2018
  19. Johannes SchindelinOct 25, 2018
  20. Junio C HamanoOct 26, 2018
  21. 3/3 http: when using Secure Channel, ignore sslCAInfo by defaultJohannes Schindelin via GitGitGadget, Oct 15, 2018
  22. 0/3 Allow choosing the SSL backend cURL uses (plus related patches)Johannes Schindelin via GitGitGadget, Oct 25, 2018
  23. 1/3 http: add support for selecting SSL backends at runtimeJohannes Schindelin via GitGitGadget, Oct 25, 2018
  24. Ævar Arnfjörð BjarmasonDec 13, 2018
  25. Johannes SchindelinDec 13, 2018
  26. Johannes SchindelinDec 13, 2018
  27. 2/3 http: add support for disabling SSL revocation checks in cURLBrendan Forster via GitGitGadget, Oct 25, 2018
  28. 3/3 http: when using Secure Channel, ignore sslCAInfo by defaultJohannes Schindelin via GitGitGadget, Oct 25, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.