Skip to content

Commit af0d8b1

Browse files
pascalmullerdscho
authored andcommitted
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 #3292 Signed-off-by: Pascal Muller <[email protected]>
1 parent ddb19a8 commit af0d8b1

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

Documentation/config/http.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ http.schannelUseSSLCAInfo::
234234
when the `schannel` backend was configured via `http.sslBackend`,
235235
unless `http.schannelUseSSLCAInfo` overrides this behavior.
236236

237+
http.sslAutoClientCert::
238+
As of cURL v7.77.0, the Secure Channel backend won't automatically
239+
send client certificates from the Windows Certificate Store anymore.
240+
To opt in to the old behavior, http.sslAutoClientCert can be set.
241+
237242
http.pinnedPubkey::
238243
Public key of the https service. It may either be the filename of
239244
a PEM or DER encoded public key file or a string starting with

git-curl-compat.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,12 @@
4545
#define GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR 1
4646
#endif
4747

48+
/**
49+
* CURLSSLOPT_AUTO_CLIENT_CERT was added in 7.77.0, released in May
50+
* 2021.
51+
*/
52+
#if LIBCURL_VERSION_NUM >= 0x074d00
53+
#define GIT_CURL_HAVE_CURLSSLOPT_AUTO_CLIENT_CERT
54+
#endif
55+
4856
#endif

http.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ static int http_schannel_check_revoke_mode =
156156
*/
157157
static int http_schannel_use_ssl_cainfo;
158158

159+
static int http_auto_client_cert;
160+
159161
static int always_auth_proactively(void)
160162
{
161163
return http_proactive_auth != PROACTIVE_AUTH_NONE &&
@@ -444,6 +446,11 @@ static int http_options(const char *var, const char *value,
444446
return 0;
445447
}
446448

449+
if (!strcmp("http.sslautoclientcert", var)) {
450+
http_auto_client_cert = git_config_bool(var, value);
451+
return 0;
452+
}
453+
447454
if (!strcmp("http.minsessions", var)) {
448455
min_curl_sessions = git_config_int(var, value, ctx->kvi);
449456
if (min_curl_sessions > 1)
@@ -1061,9 +1068,20 @@ static CURL *get_curl_handle(void)
10611068
}
10621069
#endif
10631070

1064-
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend) &&
1065-
http_schannel_check_revoke_mode) {
1066-
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, http_schannel_check_revoke_mode);
1071+
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend)) {
1072+
long ssl_options = 0;
1073+
if (http_schannel_check_revoke_mode) {
1074+
ssl_options |= http_schannel_check_revoke_mode;
1075+
}
1076+
1077+
if (http_auto_client_cert) {
1078+
#ifdef GIT_CURL_HAVE_CURLSSLOPT_AUTO_CLIENT_CERT
1079+
ssl_options |= CURLSSLOPT_AUTO_CLIENT_CERT;
1080+
#endif
1081+
}
1082+
1083+
if (ssl_options)
1084+
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, ssl_options);
10671085
}
10681086

10691087
if (http_proactive_auth != PROACTIVE_AUTH_NONE)

0 commit comments

Comments
 (0)