Skip to content

Commit c7a4626

Browse files
committed
Merge branch 'http-ssl-backend'
This topic branch brings support for choosing cURL's SSL backend at runtime via http.sslBackend, based on patches already submitted to the cURL project and backported to cURL 7.54.1 as used in Git for Windows' SDK. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents cfb90ae + 754b561 commit c7a4626

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

Documentation/config.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,6 +2020,11 @@ http.sslCAPath::
20202020
with when fetching or pushing over HTTPS. Can be overridden
20212021
by the `GIT_SSL_CAPATH` environment variable.
20222022

2023+
http.sslBackend::
2024+
Name of the SSL backend to use (e.g. "openssl" or "schannel").
2025+
This option is ignored if cURL lacks support for choosing the SSL
2026+
backend at runtime.
2027+
20232028
http.pinnedpubkey::
20242029
Public key of the https service. It may either be the filename of
20252030
a PEM or DER encoded public key file or a string starting with

http.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ static struct active_request_slot *active_queue_head;
149149

150150
static char *cached_accept_language;
151151

152+
static char *http_ssl_backend;
153+
152154
size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
153155
{
154156
size_t size = eltsize * nmemb;
@@ -296,6 +298,12 @@ static int http_options(const char *var, const char *value, void *cb)
296298
curl_ssl_try = git_config_bool(var, value);
297299
return 0;
298300
}
301+
if (!strcmp("http.sslbackend", var)) {
302+
free(http_ssl_backend);
303+
http_ssl_backend = xstrdup_or_null(value);
304+
return 0;
305+
}
306+
299307
if (!strcmp("http.minsessions", var)) {
300308
min_curl_sessions = git_config_int(var, value);
301309
#ifndef USE_CURL_MULTI
@@ -1004,6 +1012,33 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
10041012
git_config(urlmatch_config_entry, &config);
10051013
free(normalized_url);
10061014

1015+
#if LIBCURL_VERSION_NUM >= 0x073800
1016+
if (http_ssl_backend) {
1017+
const curl_ssl_backend **backends;
1018+
struct strbuf buf = STRBUF_INIT;
1019+
int i;
1020+
1021+
switch (curl_global_sslset(-1, http_ssl_backend, &backends)) {
1022+
case CURLSSLSET_UNKNOWN_BACKEND:
1023+
strbuf_addf(&buf, _("Unsupported SSL backend '%s'. "
1024+
"Supported SSL backends:"),
1025+
http_ssl_backend);
1026+
for (i = 0; backends[i]; i++)
1027+
strbuf_addf(&buf, "\n\t%s", backends[i]->name);
1028+
die("%s", buf.buf);
1029+
case CURLSSLSET_NO_BACKENDS:
1030+
die(_("Could not set SSL backend to '%s': "
1031+
"cURL was built without SSL backends"),
1032+
http_ssl_backend);
1033+
case CURLSSLSET_TOO_LATE:
1034+
die(_("Could not set SSL backend to '%s': already set"),
1035+
http_ssl_backend);
1036+
case CURLSSLSET_OK:
1037+
break; /* Okay! */
1038+
}
1039+
}
1040+
#endif
1041+
10071042
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
10081043
die("curl_global_init failed");
10091044

0 commit comments

Comments
 (0)