http: add support for specifying an SSL cipher list

Teach git about a new option, "http.sslCipherList", which permits one to specify a list of ciphers to use when negotiating SSL connections. The setting can be overwridden by the GIT_SSL_CIPHER_LIST environment variable. Signed-off-by: Lars Kellogg-Stedman <lars@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Lars Kellogg-Stedman committed May 8, 2015 at 09:22 UTC f6f2a9e42d14e61429af418d8038aa67049b3821
3 files changed +24
Documentation/config.txt
+13
@@ -1561,6 +1561,19 @@ http.savecookies::
1561 If set, store cookies received during requests to the file specified by
1562 http.cookiefile. Has no effect if http.cookiefile is unset.
1563
1564 +http.sslCipherList::
1565 + A list of SSL ciphers to use when negotiating an SSL connection.
1566 + The available ciphers depend on whether libcurl was built against
1567 + NSS or OpenSSL and the particular configuration of the crypto
1568 + library in use. Internally this sets the 'CURLOPT_SSL_CIPHER_LIST'
1569 + option; see the libcurl documentation for more details on the format
1570 + of this list.
1571 ++
1572 +Can be overridden by the 'GIT_SSL_CIPHER_LIST' environment variable.
1573 +To force git to use libcurl's default cipher list and ignore any
1574 +explicit http.sslCipherList option, set 'GIT_SSL_CIPHER_LIST' to the
1575 +empty string.
1576 +
1577 http.sslVerify::
1578 Whether to verify the SSL certificate when fetching or pushing
1579 over HTTPS. Can be overridden by the 'GIT_SSL_NO_VERIFY' environment
contrib/completion/git-completion.bash
+1
@@ -2123,6 +2123,7 @@ _git_config ()
2123 http.noEPSV
2124 http.postBuffer
2125 http.proxy
2126 + http.sslCipherList
2127 http.sslCAInfo
2128 http.sslCAPath
2129 http.sslCert
http.c
+10
@@ -35,6 +35,7 @@ char curl_errorstr[CURL_ERROR_SIZE];
35 static int curl_ssl_verify = -1;
36 static int curl_ssl_try;
37 static const char *ssl_cert;
38 +static const char *ssl_cipherlist;
39 #if LIBCURL_VERSION_NUM >= 0x070903
40 static const char *ssl_key;
41 #endif
@@ -153,6 +154,8 @@ static int http_options(const char *var, const char *value, void *cb)
154 curl_ssl_verify = git_config_bool(var, value);
155 return 0;
156 }
157 + if (!strcmp("http.sslcipherlist", var))
158 + return git_config_string(&ssl_cipherlist, var, value);
159 if (!strcmp("http.sslcert", var))
160 return git_config_string(&ssl_cert, var, value);
161 #if LIBCURL_VERSION_NUM >= 0x070903
@@ -327,6 +330,13 @@ static CURL *get_curl_handle(void)
330 if (http_proactive_auth)
331 init_curl_http_auth(result);
332
333 + if (getenv("GIT_SSL_CIPHER_LIST"))
334 + ssl_cipherlist = getenv("GIT_SSL_CIPHER_LIST");
335 +
336 + if (ssl_cipherlist != NULL && *ssl_cipherlist)
337 + curl_easy_setopt(result, CURLOPT_SSL_CIPHER_LIST,
338 + ssl_cipherlist);
339 +
340 if (ssl_cert != NULL)
341 curl_easy_setopt(result, CURLOPT_SSLCERT, ssl_cert);
342 if (has_cert_password())