Skip to content

Commit 9624e70

Browse files
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 b154dbf + f3a8521 commit 9624e70

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
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
@@ -143,4 +143,12 @@
143143
#define GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR 1
144144
#endif
145145

146+
/**
147+
* CURLSSLOPT_AUTO_CLIENT_CERT was added in 7.77.0, released in May
148+
* 2021.
149+
*/
150+
#if LIBCURL_VERSION_NUM >= 0x074d00
151+
#define GIT_CURL_HAVE_CURLSSLOPT_AUTO_CLIENT_CERT
152+
#endif
153+
146154
#endif

http.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ static int http_schannel_check_revoke_mode =
161161
*/
162162
static int http_schannel_use_ssl_cainfo;
163163

164+
static int http_auto_client_cert;
165+
164166
static int always_auth_proactively(void)
165167
{
166168
return http_proactive_auth != PROACTIVE_AUTH_NONE &&
@@ -449,6 +451,11 @@ static int http_options(const char *var, const char *value,
449451
return 0;
450452
}
451453

454+
if (!strcmp("http.sslautoclientcert", var)) {
455+
http_auto_client_cert = git_config_bool(var, value);
456+
return 0;
457+
}
458+
452459
if (!strcmp("http.minsessions", var)) {
453460
min_curl_sessions = git_config_int(var, value, ctx->kvi);
454461
if (min_curl_sessions > 1)
@@ -1102,13 +1109,24 @@ static CURL *get_curl_handle(void)
11021109
}
11031110
#endif
11041111

1105-
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend) &&
1106-
http_schannel_check_revoke_mode) {
1112+
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend)) {
1113+
long ssl_options = 0;
1114+
if (http_schannel_check_revoke_mode) {
11071115
#ifdef GIT_CURL_HAVE_CURLSSLOPT_NO_REVOKE
1108-
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, http_schannel_check_revoke_mode);
1116+
ssl_options |= http_schannel_check_revoke_mode;
11091117
#else
1110-
warning(_("CURLSSLOPT_NO_REVOKE not supported with cURL < 7.44.0"));
1118+
warning(_("CURLSSLOPT_NO_REVOKE not supported with cURL < 7.44.0"));
11111119
#endif
1120+
}
1121+
1122+
if (http_auto_client_cert) {
1123+
#ifdef GIT_CURL_HAVE_CURLSSLOPT_AUTO_CLIENT_CERT
1124+
ssl_options |= CURLSSLOPT_AUTO_CLIENT_CERT;
1125+
#endif
1126+
}
1127+
1128+
if (ssl_options)
1129+
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, ssl_options);
11121130
}
11131131

11141132
if (http_proactive_auth != PROACTIVE_AUTH_NONE)

0 commit comments

Comments
 (0)