Skip to content

Commit 46c25af

Browse files
committed
http: optionally send SSL client certificate
This adds support for a new http.sslAutoClientCert config value. In cURL 7.77 or later the schannel backend does not automatically send client certificates from the Windows Certificate Store anymore. This config value is only used if http.sslBackend is set to "schannel", and can be used to opt in to the old behavior and force cURL to send client certificates. This fixes git-for-windows#3292 Signed-off-by: Pascal Muller <[email protected]>
1 parent 47d5684 commit 46c25af

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

Documentation/config/http.txt

+5
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ http.schannelUseSSLCAInfo::
189189
when the `schannel` backend was configured via `http.sslBackend`,
190190
unless `http.schannelUseSSLCAInfo` overrides this behavior.
191191

192+
http.sslAutoClientCert::
193+
As of cURL v7.77.0, the Secure Channel backend won't automatically
194+
send client certificates from the Windows Certificate Store anymore.
195+
To opt in to the old behavior, http.sslAutoClientCert can be set.
196+
192197
http.pinnedpubkey::
193198
Public key of the https service. It may either be the filename of
194199
a PEM or DER encoded public key file or a string starting with

http.c

+23-4
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ static int http_schannel_check_revoke_mode =
179179
*/
180180
static int http_schannel_use_ssl_cainfo;
181181

182+
static int http_schannel_auto_client_cert = 0;
183+
182184
size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
183185
{
184186
size_t size = eltsize * nmemb;
@@ -357,6 +359,11 @@ static int http_options(const char *var, const char *value, void *cb)
357359
return 0;
358360
}
359361

362+
if (!strcmp("http.sslautoclientcert", var)) {
363+
http_schannel_auto_client_cert = git_config_bool(var, value);
364+
return 0;
365+
}
366+
360367
if (!strcmp("http.minsessions", var)) {
361368
min_curl_sessions = git_config_int(var, value);
362369
#ifndef USE_CURL_MULTI
@@ -920,13 +927,25 @@ static CURL *get_curl_handle(void)
920927
}
921928
#endif
922929

923-
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend) &&
924-
http_schannel_check_revoke_mode) {
930+
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend)) {
931+
long ssl_options = 0;
932+
if (http_schannel_check_revoke_mode) {
925933
#if LIBCURL_VERSION_NUM >= 0x072c00
926-
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, http_schannel_check_revoke_mode);
934+
ssl_options |= http_schannel_check_revoke_mode;
927935
#else
928-
warning(_("CURLSSLOPT_NO_REVOKE not supported with cURL < 7.44.0"));
936+
warning(_("CURLSSLOPT_NO_REVOKE not supported with cURL < 7.44.0"));
929937
#endif
938+
}
939+
940+
if (http_schannel_auto_client_cert) {
941+
#if LIBCURL_VERSION_NUM >= 0x074d00
942+
ssl_options |= CURLSSLOPT_AUTO_CLIENT_CERT;
943+
#endif
944+
}
945+
946+
if (ssl_options != 0) {
947+
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, ssl_options);
948+
}
930949
}
931950

932951
if (http_proactive_auth)

0 commit comments

Comments
 (0)