Skip to content

Commit fe487ac

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 8900c99 + be84f2c commit fe487ac

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

Documentation/config/http.adoc

+5
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ http.schannelUseSSLCAInfo::
249249
when the `schannel` backend was configured via `http.sslBackend`,
250250
unless `http.schannelUseSSLCAInfo` overrides this behavior.
251251

252+
http.sslAutoClientCert::
253+
As of cURL v7.77.0, the Secure Channel backend won't automatically
254+
send client certificates from the Windows Certificate Store anymore.
255+
To opt in to the old behavior, http.sslAutoClientCert can be set.
256+
252257
http.pinnedPubkey::
253258
Public key of the https service. It may either be the filename of
254259
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)
@@ -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)