Skip to content

Commit 630b73e

Browse files
dschoGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
Merge pull request #3293 from pascalmuller/http-support-automatically-sending-client-certificate
http: Add support for enabling automatic sending of SSL client certificate
2 parents 8f2c8ee + 66f631c commit 630b73e

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

Documentation/config/http.txt

+5
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

+8
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

+21-3
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ static int http_schannel_check_revoke_mode =
157157
*/
158158
static int http_schannel_use_ssl_cainfo;
159159

160+
static int http_auto_client_cert;
161+
160162
static int always_auth_proactively(void)
161163
{
162164
return http_proactive_auth != PROACTIVE_AUTH_NONE &&
@@ -445,6 +447,11 @@ static int http_options(const char *var, const char *value,
445447
return 0;
446448
}
447449

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

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

10701088
if (http_proactive_auth != PROACTIVE_AUTH_NONE)

0 commit comments

Comments
 (0)