Skip to content

Commit 69a8799

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 f09887d commit 69a8799

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

Documentation/config/http.txt

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

+8
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,12 @@
126126
#define GIT_CURL_HAVE_CURLSSLSET_NO_BACKENDS
127127
#endif
128128

129+
/**
130+
* CURLSSLOPT_AUTO_CLIENT_CERT was added in 7.77.0, released in May
131+
* 2021.
132+
*/
133+
#if LIBCURL_VERSION_NUM >= 0x074d00
134+
#define GIT_CURL_HAVE_CURLSSLOPT_AUTO_CLIENT_CERT
135+
#endif
136+
129137
#endif

http.c

+22-4
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ static int http_schannel_check_revoke_mode =
150150
*/
151151
static int http_schannel_use_ssl_cainfo;
152152

153+
static int http_auto_client_cert;
154+
153155
size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
154156
{
155157
size_t size = eltsize * nmemb;
@@ -314,6 +316,11 @@ static int http_options(const char *var, const char *value, void *cb)
314316
return 0;
315317
}
316318

319+
if (!strcmp("http.sslautoclientcert", var)) {
320+
http_auto_client_cert = git_config_bool(var, value);
321+
return 0;
322+
}
323+
317324
if (!strcmp("http.minsessions", var)) {
318325
min_curl_sessions = git_config_int(var, value);
319326
if (min_curl_sessions > 1)
@@ -871,13 +878,24 @@ static CURL *get_curl_handle(void)
871878
}
872879
#endif
873880

874-
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend) &&
875-
http_schannel_check_revoke_mode) {
881+
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend)) {
882+
long ssl_options = 0;
883+
if (http_schannel_check_revoke_mode) {
876884
#ifdef GIT_CURL_HAVE_CURLSSLOPT_NO_REVOKE
877-
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, http_schannel_check_revoke_mode);
885+
ssl_options |= http_schannel_check_revoke_mode;
878886
#else
879-
warning(_("CURLSSLOPT_NO_REVOKE not supported with cURL < 7.44.0"));
887+
warning(_("CURLSSLOPT_NO_REVOKE not supported with cURL < 7.44.0"));
880888
#endif
889+
}
890+
891+
if (http_auto_client_cert) {
892+
#ifdef GIT_CURL_HAVE_CURLSSLOPT_AUTO_CLIENT_CERT
893+
ssl_options |= CURLSSLOPT_AUTO_CLIENT_CERT;
894+
#endif
895+
}
896+
897+
if (ssl_options)
898+
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, ssl_options);
881899
}
882900

883901
if (http_proactive_auth)

0 commit comments

Comments
 (0)