Skip to content

Commit 583de49

Browse files
dschoGit for Windows Build Agent
authored andcommitted
http: add support for selecting SSL backends at runtime
The Pull Request at curl/curl#1601 adds support for choosing the SSL backend at runtime to cURL, and will hopefully be merged before version 7.56.0 comes out. Git for Windows will ship with those patches backported to 7.54.1 (and come August 9th, 2017, 7.55.0 and later). This patch adds the Git side of that feature: by setting http.sslBackend to "openssl" or "schannel", Git for Windows can now choose the SSL backend at runtime. This comes in handy because Secure Channel ("schannel") is the native Windows solution, accessing the Windows Credential Store, thereby allowing for enterprise-wide management of certificates. For historical reasons, Git for Windows needs to support OpenSSL still, as it has previously been the only supported SSL backend in Git for Windows for almost a decade. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 3070434 commit 583de49

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

1980+
http.sslBackend::
1981+
Name of the SSL backend to use (e.g. "openssl" or "schannel").
1982+
This option is ignored if cURL lacks support for choosing the SSL
1983+
backend at runtime.
1984+
19801985
http.pinnedpubkey::
19811986
Public key of the https service. It may either be the filename of
19821987
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
@@ -146,6 +146,8 @@ static struct active_request_slot *active_queue_head;
146146

147147
static char *cached_accept_language;
148148

149+
static char *http_ssl_backend;
150+
149151
size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
150152
{
151153
size_t size = eltsize * nmemb;
@@ -293,6 +295,12 @@ static int http_options(const char *var, const char *value, void *cb)
293295
curl_ssl_try = git_config_bool(var, value);
294296
return 0;
295297
}
298+
if (!strcmp("http.sslbackend", var)) {
299+
free(http_ssl_backend);
300+
http_ssl_backend = xstrdup_or_null(value);
301+
return 0;
302+
}
303+
296304
if (!strcmp("http.minsessions", var)) {
297305
min_curl_sessions = git_config_int(var, value);
298306
#ifndef USE_CURL_MULTI
@@ -933,6 +941,33 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
933941
git_config(urlmatch_config_entry, &config);
934942
free(normalized_url);
935943

944+
#if LIBCURL_VERSION_NUM >= 0x073800
945+
if (http_ssl_backend) {
946+
const curl_ssl_backend **backends;
947+
struct strbuf buf = STRBUF_INIT;
948+
int i;
949+
950+
switch (curl_global_sslset(-1, http_ssl_backend, &backends)) {
951+
case CURLSSLSET_UNKNOWN_BACKEND:
952+
strbuf_addf(&buf, _("Unsupported SSL backend '%s'. "
953+
"Supported SSL backends:"),
954+
http_ssl_backend);
955+
for (i = 0; backends[i]; i++)
956+
strbuf_addf(&buf, "\n\t%s", backends[i]->name);
957+
die("%s", buf.buf);
958+
case CURLSSLSET_NO_BACKENDS:
959+
die(_("Could not set SSL backend to '%s': "
960+
"cURL was built without SSL backends"),
961+
http_ssl_backend);
962+
case CURLSSLSET_TOO_LATE:
963+
die(_("Could not set SSL backend to '%s': already set"),
964+
http_ssl_backend);
965+
case CURLSSLSET_OK:
966+
break; /* Okay! */
967+
}
968+
}
969+
#endif
970+
936971
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
937972
die("curl_global_init failed");
938973

0 commit comments

Comments
 (0)