Skip to content

Commit 70c1ff8

Browse files
committed
fixup! http: add support for selecting SSL backends at runtime
This change delays configuring the SSL backend until just before curl_global_init(). Rationale: we now support the system gitconfig to say something different than, say, the command-line config (before, cURL would say that the SSL backend had been configured already). Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 82d9b3f commit 70c1ff8

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

http.c

Lines changed: 29 additions & 20 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,28 +293,11 @@ 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
}
294-
#if LIBCURL_VERSION_NUM >= 0x073800 || \
295-
defined(CURL_WITH_EXPERIMENTAL_SSL_BACKEND_SUPPORT)
296296
if (!strcmp("http.sslbackend", var)) {
297-
const curl_ssl_backend **backends;
298-
struct strbuf buf = STRBUF_INIT;
299-
int i;
300-
301-
switch (curl_global_sslset(-1, value, &backends)) {
302-
case CURLSSLSET_UNKNOWN_BACKEND:
303-
strbuf_addf(&buf, _("Unsupported SSL backend '%s'. "
304-
"Supported SSL backends:"), value);
305-
for (i = 0; backends[i]; i++)
306-
strbuf_addf(&buf, "\n\t%s", backends[i]->name);
307-
die(buf.buf);
308-
case CURLSSLSET_TOO_LATE:
309-
die(_("Could not set SSL backend to '%s': already set"),
310-
value);
311-
case CURLSSLSET_OK:
312-
break; /* Okay! */
313-
}
297+
free(http_ssl_backend);
298+
http_ssl_backend = xstrdup_or_null(value);
299+
return 0;
314300
}
315-
#endif
316301

317302
if (!strcmp("http.minsessions", var)) {
318303
min_curl_sessions = git_config_int(var, value);
@@ -936,6 +921,30 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
936921
git_config(urlmatch_config_entry, &config);
937922
free(normalized_url);
938923

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

0 commit comments

Comments
 (0)