Skip to content

Commit 38b099a

Browse files
dschoGit for Windows Build Agent
authored andcommitted
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 47e5444 + 5aa5182 commit 38b099a

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
@@ -189,6 +189,11 @@ http.schannelUseSSLCAInfo::
189189
when the `schannel` backend was configured via `http.sslBackend`,
190190
unless `http.schannelUseSSLCAInfo` overrides this behavior.
191191

192+
http.sslAutoClientCert::
193+
As of cURL v7.77.0, the Secure Channel backend won't automatically
194+
send client certificates from the Windows Certificate Store anymore.
195+
To opt in to the old behavior, http.sslAutoClientCert can be set.
196+
192197
http.pinnedpubkey::
193198
Public key of the https service. It may either be the filename of
194199
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
@@ -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

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ static int http_schannel_check_revoke_mode =
148148
*/
149149
static int http_schannel_use_ssl_cainfo;
150150

151+
static int http_auto_client_cert;
152+
151153
size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
152154
{
153155
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)
@@ -822,13 +829,24 @@ static CURL *get_curl_handle(void)
822829
}
823830
#endif
824831

825-
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend) &&
826-
http_schannel_check_revoke_mode) {
832+
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend)) {
833+
long ssl_options = 0;
834+
if (http_schannel_check_revoke_mode) {
827835
#ifdef GIT_CURL_HAVE_CURLSSLOPT_NO_REVOKE
828-
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, http_schannel_check_revoke_mode);
836+
ssl_options |= http_schannel_check_revoke_mode;
829837
#else
830-
warning(_("CURLSSLOPT_NO_REVOKE not supported with cURL < 7.44.0"));
838+
warning(_("CURLSSLOPT_NO_REVOKE not supported with cURL < 7.44.0"));
831839
#endif
840+
}
841+
842+
if (http_auto_client_cert) {
843+
#ifdef GIT_CURL_HAVE_CURLSSLOPT_AUTO_CLIENT_CERT
844+
ssl_options |= CURLSSLOPT_AUTO_CLIENT_CERT;
845+
#endif
846+
}
847+
848+
if (ssl_options)
849+
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, ssl_options);
832850
}
833851

834852
if (http_proactive_auth)

0 commit comments

Comments
 (0)