Skip to content

Commit d6ba41a

Browse files
author
Git for Windows Build Agent
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 8822796 + 5579434 commit d6ba41a

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

2001+
http.sslBackend::
2002+
Name of the SSL backend to use (e.g. "openssl" or "schannel").
2003+
This option is ignored if cURL lacks support for choosing the SSL
2004+
backend at runtime.
2005+
20012006
http.pinnedpubkey::
20022007
Public key of the https service. It may either be the filename of
20032008
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
@@ -116,6 +116,8 @@ static struct active_request_slot *active_queue_head;
116116

117117
static char *cached_accept_language;
118118

119+
static char *http_ssl_backend;
120+
119121
size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
120122
{
121123
size_t size = eltsize * nmemb;
@@ -249,6 +251,12 @@ static int http_options(const char *var, const char *value, void *cb)
249251
curl_ssl_try = git_config_bool(var, value);
250252
return 0;
251253
}
254+
if (!strcmp("http.sslbackend", var)) {
255+
free(http_ssl_backend);
256+
http_ssl_backend = xstrdup_or_null(value);
257+
return 0;
258+
}
259+
252260
if (!strcmp("http.minsessions", var)) {
253261
min_curl_sessions = git_config_int(var, value);
254262
if (min_curl_sessions > 1)
@@ -829,6 +837,33 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
829837
git_config(urlmatch_config_entry, &config);
830838
free(normalized_url);
831839

840+
#if LIBCURL_VERSION_NUM >= 0x073800
841+
if (http_ssl_backend) {
842+
const curl_ssl_backend **backends;
843+
struct strbuf buf = STRBUF_INIT;
844+
int i;
845+
846+
switch (curl_global_sslset(-1, http_ssl_backend, &backends)) {
847+
case CURLSSLSET_UNKNOWN_BACKEND:
848+
strbuf_addf(&buf, _("Unsupported SSL backend '%s'. "
849+
"Supported SSL backends:"),
850+
http_ssl_backend);
851+
for (i = 0; backends[i]; i++)
852+
strbuf_addf(&buf, "\n\t%s", backends[i]->name);
853+
die("%s", buf.buf);
854+
case CURLSSLSET_NO_BACKENDS:
855+
die(_("Could not set SSL backend to '%s': "
856+
"cURL was built without SSL backends"),
857+
http_ssl_backend);
858+
case CURLSSLSET_TOO_LATE:
859+
die(_("Could not set SSL backend to '%s': already set"),
860+
http_ssl_backend);
861+
case CURLSSLSET_OK:
862+
break; /* Okay! */
863+
}
864+
}
865+
#endif
866+
832867
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
833868
die("curl_global_init failed");
834869

0 commit comments

Comments
 (0)