Skip to content

Commit d6480d9

Browse files
pascalmullermjcheetham
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 0d6d69d commit d6480d9

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
@@ -205,6 +205,11 @@ http.schannelUseSSLCAInfo::
205205
when the `schannel` backend was configured via `http.sslBackend`,
206206
unless `http.schannelUseSSLCAInfo` overrides this behavior.
207207

208+
http.sslAutoClientCert::
209+
As of cURL v7.77.0, the Secure Channel backend won't automatically
210+
send client certificates from the Windows Certificate Store anymore.
211+
To opt in to the old behavior, http.sslAutoClientCert can be set.
212+
208213
http.pinnedPubkey::
209214
Public key of the https service. It may either be the filename of
210215
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
@@ -134,4 +134,12 @@
134134
#define GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR 1
135135
#endif
136136

137+
/**
138+
* CURLSSLOPT_AUTO_CLIENT_CERT was added in 7.77.0, released in May
139+
* 2021.
140+
*/
141+
#if LIBCURL_VERSION_NUM >= 0x074d00
142+
#define GIT_CURL_HAVE_CURLSSLOPT_AUTO_CLIENT_CERT
143+
#endif
144+
137145
#endif

http.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ static int http_schannel_check_revoke_mode =
155155
*/
156156
static int http_schannel_use_ssl_cainfo;
157157

158+
static int http_auto_client_cert;
159+
158160
size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
159161
{
160162
size_t size = eltsize * nmemb;
@@ -430,6 +432,11 @@ static int http_options(const char *var, const char *value, void *cb)
430432
return 0;
431433
}
432434

435+
if (!strcmp("http.sslautoclientcert", var)) {
436+
http_auto_client_cert = git_config_bool(var, value);
437+
return 0;
438+
}
439+
433440
if (!strcmp("http.minsessions", var)) {
434441
min_curl_sessions = git_config_int(var, value);
435442
if (min_curl_sessions > 1)
@@ -1004,13 +1011,24 @@ static CURL *get_curl_handle(void)
10041011
}
10051012
#endif
10061013

1007-
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend) &&
1008-
http_schannel_check_revoke_mode) {
1014+
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend)) {
1015+
long ssl_options = 0;
1016+
if (http_schannel_check_revoke_mode) {
10091017
#ifdef GIT_CURL_HAVE_CURLSSLOPT_NO_REVOKE
1010-
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, http_schannel_check_revoke_mode);
1018+
ssl_options |= http_schannel_check_revoke_mode;
10111019
#else
1012-
warning(_("CURLSSLOPT_NO_REVOKE not supported with cURL < 7.44.0"));
1020+
warning(_("CURLSSLOPT_NO_REVOKE not supported with cURL < 7.44.0"));
10131021
#endif
1022+
}
1023+
1024+
if (http_auto_client_cert) {
1025+
#ifdef GIT_CURL_HAVE_CURLSSLOPT_AUTO_CLIENT_CERT
1026+
ssl_options |= CURLSSLOPT_AUTO_CLIENT_CERT;
1027+
#endif
1028+
}
1029+
1030+
if (ssl_options)
1031+
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, ssl_options);
10141032
}
10151033

10161034
if (http_proactive_auth)

0 commit comments

Comments
 (0)