Skip to content

Commit e77777b

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 2c62e3f + dc1f862 commit e77777b

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
@@ -2029,6 +2029,11 @@ http.sslCAPath::
20292029
with when fetching or pushing over HTTPS. Can be overridden
20302030
by the `GIT_SSL_CAPATH` environment variable.
20312031

2032+
http.sslBackend::
2033+
Name of the SSL backend to use (e.g. "openssl" or "schannel").
2034+
This option is ignored if cURL lacks support for choosing the SSL
2035+
backend at runtime.
2036+
20322037
http.pinnedpubkey::
20332038
Public key of the https service. It may either be the filename of
20342039
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
@@ -151,6 +151,8 @@ static struct active_request_slot *active_queue_head;
151151

152152
static char *cached_accept_language;
153153

154+
static char *http_ssl_backend;
155+
154156
size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
155157
{
156158
size_t size = eltsize * nmemb;
@@ -298,6 +300,12 @@ static int http_options(const char *var, const char *value, void *cb)
298300
curl_ssl_try = git_config_bool(var, value);
299301
return 0;
300302
}
303+
if (!strcmp("http.sslbackend", var)) {
304+
free(http_ssl_backend);
305+
http_ssl_backend = xstrdup_or_null(value);
306+
return 0;
307+
}
308+
301309
if (!strcmp("http.minsessions", var)) {
302310
min_curl_sessions = git_config_int(var, value);
303311
#ifndef USE_CURL_MULTI
@@ -1006,6 +1014,33 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
10061014
git_config(urlmatch_config_entry, &config);
10071015
free(normalized_url);
10081016

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

0 commit comments

Comments
 (0)