Skip to content

Commit 573dbac

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 072351a + d1752b8 commit 573dbac

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
@@ -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;
@@ -312,6 +314,11 @@ static int http_options(const char *var, const char *value, void *cb)
312314
return 0;
313315
}
314316

317+
if (!strcmp("http.sslautoclientcert", var)) {
318+
http_auto_client_cert = git_config_bool(var, value);
319+
return 0;
320+
}
321+
315322
if (!strcmp("http.minsessions", var)) {
316323
min_curl_sessions = git_config_int(var, value);
317324
if (min_curl_sessions > 1)
@@ -886,13 +893,24 @@ static CURL *get_curl_handle(void)
886893
}
887894
#endif
888895

889-
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend) &&
890-
http_schannel_check_revoke_mode) {
896+
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend)) {
897+
long ssl_options = 0;
898+
if (http_schannel_check_revoke_mode) {
891899
#ifdef GIT_CURL_HAVE_CURLSSLOPT_NO_REVOKE
892-
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, http_schannel_check_revoke_mode);
900+
ssl_options |= http_schannel_check_revoke_mode;
893901
#else
894-
warning(_("CURLSSLOPT_NO_REVOKE not supported with cURL < 7.44.0"));
902+
warning(_("CURLSSLOPT_NO_REVOKE not supported with cURL < 7.44.0"));
895903
#endif
904+
}
905+
906+
if (http_auto_client_cert) {
907+
#ifdef GIT_CURL_HAVE_CURLSSLOPT_AUTO_CLIENT_CERT
908+
ssl_options |= CURLSSLOPT_AUTO_CLIENT_CERT;
909+
#endif
910+
}
911+
912+
if (ssl_options)
913+
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, ssl_options);
896914
}
897915

898916
if (http_proactive_auth)

0 commit comments

Comments
 (0)