Skip to content

Commit 0e76cac

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 1bcc284 + 25c0449 commit 0e76cac

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;
@@ -432,6 +434,11 @@ static int http_options(const char *var, const char *value,
432434
return 0;
433435
}
434436

437+
if (!strcmp("http.sslautoclientcert", var)) {
438+
http_auto_client_cert = git_config_bool(var, value);
439+
return 0;
440+
}
441+
435442
if (!strcmp("http.minsessions", var)) {
436443
min_curl_sessions = git_config_int(var, value, ctx->kvi);
437444
if (min_curl_sessions > 1)
@@ -1034,13 +1041,24 @@ static CURL *get_curl_handle(void)
10341041
}
10351042
#endif
10361043

1037-
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend) &&
1038-
http_schannel_check_revoke_mode) {
1044+
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend)) {
1045+
long ssl_options = 0;
1046+
if (http_schannel_check_revoke_mode) {
10391047
#ifdef GIT_CURL_HAVE_CURLSSLOPT_NO_REVOKE
1040-
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, http_schannel_check_revoke_mode);
1048+
ssl_options |= http_schannel_check_revoke_mode;
10411049
#else
1042-
warning(_("CURLSSLOPT_NO_REVOKE not supported with cURL < 7.44.0"));
1050+
warning(_("CURLSSLOPT_NO_REVOKE not supported with cURL < 7.44.0"));
10431051
#endif
1052+
}
1053+
1054+
if (http_auto_client_cert) {
1055+
#ifdef GIT_CURL_HAVE_CURLSSLOPT_AUTO_CLIENT_CERT
1056+
ssl_options |= CURLSSLOPT_AUTO_CLIENT_CERT;
1057+
#endif
1058+
}
1059+
1060+
if (ssl_options)
1061+
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, ssl_options);
10441062
}
10451063

10461064
if (http_proactive_auth)

0 commit comments

Comments
 (0)