Skip to content

Commit ed070a4

Browse files
committed
Merge branch 'ep/http-configure-ssl-version'
A new configuration variable http.sslVersion can be used to specify what specific version of SSL/TLS to use to make a connection. * ep/http-configure-ssl-version: http: add support for specifying the SSL version
2 parents 51e83a4 + 01861cb commit ed070a4

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

Documentation/config.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,29 @@ http.saveCookies::
16091609
If set, store cookies received during requests to the file specified by
16101610
http.cookieFile. Has no effect if http.cookieFile is unset.
16111611

1612+
http.sslVersion::
1613+
The SSL version to use when negotiating an SSL connection, if you
1614+
want to force the default. The available and default version
1615+
depend on whether libcurl was built against NSS or OpenSSL and the
1616+
particular configuration of the crypto library in use. Internally
1617+
this sets the 'CURLOPT_SSL_VERSION' option; see the libcurl
1618+
documentation for more details on the format of this option and
1619+
for the ssl version supported. Actually the possible values of
1620+
this option are:
1621+
1622+
- sslv2
1623+
- sslv3
1624+
- tlsv1
1625+
- tlsv1.0
1626+
- tlsv1.1
1627+
- tlsv1.2
1628+
1629+
+
1630+
Can be overridden by the 'GIT_SSL_VERSION' environment variable.
1631+
To force git to use libcurl's default ssl version and ignore any
1632+
explicit http.sslversion option, set 'GIT_SSL_VERSION' to the
1633+
empty string.
1634+
16121635
http.sslCipherList::
16131636
A list of SSL ciphers to use when negotiating an SSL connection.
16141637
The available ciphers depend on whether libcurl was built against

contrib/completion/git-completion.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,6 +2121,7 @@ _git_config ()
21212121
http.postBuffer
21222122
http.proxy
21232123
http.sslCipherList
2124+
http.sslVersion
21242125
http.sslCAInfo
21252126
http.sslCAPath
21262127
http.sslCert

http.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ static int curl_ssl_verify = -1;
3737
static int curl_ssl_try;
3838
static const char *ssl_cert;
3939
static const char *ssl_cipherlist;
40+
static const char *ssl_version;
41+
static struct {
42+
const char *name;
43+
long ssl_version;
44+
} sslversions[] = {
45+
{ "sslv2", CURL_SSLVERSION_SSLv2 },
46+
{ "sslv3", CURL_SSLVERSION_SSLv3 },
47+
{ "tlsv1", CURL_SSLVERSION_TLSv1 },
48+
#if LIBCURL_VERSION_NUM >= 0x072200
49+
{ "tlsv1.0", CURL_SSLVERSION_TLSv1_0 },
50+
{ "tlsv1.1", CURL_SSLVERSION_TLSv1_1 },
51+
{ "tlsv1.2", CURL_SSLVERSION_TLSv1_2 },
52+
#endif
53+
};
4054
#if LIBCURL_VERSION_NUM >= 0x070903
4155
static const char *ssl_key;
4256
#endif
@@ -190,6 +204,8 @@ static int http_options(const char *var, const char *value, void *cb)
190204
}
191205
if (!strcmp("http.sslcipherlist", var))
192206
return git_config_string(&ssl_cipherlist, var, value);
207+
if (!strcmp("http.sslversion", var))
208+
return git_config_string(&ssl_version, var, value);
193209
if (!strcmp("http.sslcert", var))
194210
return git_config_string(&ssl_cert, var, value);
195211
#if LIBCURL_VERSION_NUM >= 0x070903
@@ -364,9 +380,24 @@ static CURL *get_curl_handle(void)
364380
if (http_proactive_auth)
365381
init_curl_http_auth(result);
366382

383+
if (getenv("GIT_SSL_VERSION"))
384+
ssl_version = getenv("GIT_SSL_VERSION");
385+
if (ssl_version && *ssl_version) {
386+
int i;
387+
for (i = 0; i < ARRAY_SIZE(sslversions); i++) {
388+
if (!strcmp(ssl_version, sslversions[i].name)) {
389+
curl_easy_setopt(result, CURLOPT_SSLVERSION,
390+
sslversions[i].ssl_version);
391+
break;
392+
}
393+
}
394+
if (i == ARRAY_SIZE(sslversions))
395+
warning("unsupported ssl version %s: using default",
396+
ssl_version);
397+
}
398+
367399
if (getenv("GIT_SSL_CIPHER_LIST"))
368400
ssl_cipherlist = getenv("GIT_SSL_CIPHER_LIST");
369-
370401
if (ssl_cipherlist != NULL && *ssl_cipherlist)
371402
curl_easy_setopt(result, CURLOPT_SSL_CIPHER_LIST,
372403
ssl_cipherlist);

0 commit comments

Comments
 (0)