Skip to content

Commit c61d25c

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 a2ef9b9 + 2111bb3 commit c61d25c

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

1972+
http.sslBackend::
1973+
Name of the SSL backend to use (e.g. "openssl" or "schannel").
1974+
This option is ignored if cURL lacks support for choosing the SSL
1975+
backend at runtime.
1976+
19721977
http.pinnedpubkey::
19731978
Public key of the https service. It may either be the filename of
19741979
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
@@ -144,6 +144,8 @@ static struct active_request_slot *active_queue_head;
144144

145145
static char *cached_accept_language;
146146

147+
static char *http_ssl_backend;
148+
147149
size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
148150
{
149151
size_t size = eltsize * nmemb;
@@ -291,6 +293,12 @@ static int http_options(const char *var, const char *value, void *cb)
291293
curl_ssl_try = git_config_bool(var, value);
292294
return 0;
293295
}
296+
if (!strcmp("http.sslbackend", var)) {
297+
free(http_ssl_backend);
298+
http_ssl_backend = xstrdup_or_null(value);
299+
return 0;
300+
}
301+
294302
if (!strcmp("http.minsessions", var)) {
295303
min_curl_sessions = git_config_int(var, value);
296304
#ifndef USE_CURL_MULTI
@@ -913,6 +921,33 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
913921
git_config(urlmatch_config_entry, &config);
914922
free(normalized_url);
915923

924+
#if LIBCURL_VERSION_NUM >= 0x073800
925+
if (http_ssl_backend) {
926+
const curl_ssl_backend **backends;
927+
struct strbuf buf = STRBUF_INIT;
928+
int i;
929+
930+
switch (curl_global_sslset(-1, http_ssl_backend, &backends)) {
931+
case CURLSSLSET_UNKNOWN_BACKEND:
932+
strbuf_addf(&buf, _("Unsupported SSL backend '%s'. "
933+
"Supported SSL backends:"),
934+
http_ssl_backend);
935+
for (i = 0; backends[i]; i++)
936+
strbuf_addf(&buf, "\n\t%s", backends[i]->name);
937+
die("%s", buf.buf);
938+
case CURLSSLSET_NO_BACKENDS:
939+
die(_("Could not set SSL backend to '%s': "
940+
"cURL was built without SSL backends"),
941+
http_ssl_backend);
942+
case CURLSSLSET_TOO_LATE:
943+
die(_("Could not set SSL backend to '%s': already set"),
944+
http_ssl_backend);
945+
case CURLSSLSET_OK:
946+
break; /* Okay! */
947+
}
948+
}
949+
#endif
950+
916951
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
917952
die("curl_global_init failed");
918953

0 commit comments

Comments
 (0)