Support FTP-over-SSL/TLS for regular FTP
Add a boolean http.sslTry option which allows to enable AUTH SSL/TLS and encrypted data transfers when connecting via regular FTP protocol. Default is false since it might trigger certificate verification errors on misconfigured servers. Signed-off-by: Modestas Vainius <modestas@vainius.eu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Modestas Vainius committed
Apr 7, 2013 at 22:10 UTC
4bc444eb64173f770c1d1dba2ed3db393c2a9b18
3 files changed
+27
Documentation/config.txt
+8
@@ -1447,6 +1447,14 @@ http.sslCAPath::
1447
with when fetching or pushing over HTTPS. Can be overridden
1448
by the 'GIT_SSL_CAPATH' environment variable.
1449
1450
+http.sslTry::
1451
+ Attempt to use AUTH SSL/TLS and encrypted data transfers
1452
+ when connecting via regular FTP protocol. This might be needed
1453
+ if the FTP server requires it for security reasons or you wish
1454
+ to connect securely whenever remote FTP server supports it.
1455
+ Default is false since it might trigger certificate verification
1456
+ errors on misconfigured servers.
1457
+
1458
http.maxRequests::
1459
How many HTTP requests to launch in parallel. Can be overridden
1460
by the 'GIT_HTTP_MAX_REQUESTS' environment variable. Default is 5.
http.c
+10
@@ -30,6 +30,7 @@ static CURL *curl_default;
30
char curl_errorstr[CURL_ERROR_SIZE];
31
32
static int curl_ssl_verify = -1;
33
+static int curl_ssl_try;
34
static const char *ssl_cert;
35
#if LIBCURL_VERSION_NUM >= 0x070903
36
static const char *ssl_key;
@@ -162,6 +163,10 @@ static int http_options(const char *var, const char *value, void *cb)
163
ssl_cert_password_required = 1;
164
return 0;
165
}
166
+ if (!strcmp("http.ssltry", var)) {
167
+ curl_ssl_try = git_config_bool(var, value);
168
+ return 0;
169
+ }
170
if (!strcmp("http.minsessions", var)) {
171
min_curl_sessions = git_config_int(var, value);
172
#ifndef USE_CURL_MULTI
@@ -306,6 +311,11 @@ static CURL *get_curl_handle(void)
311
if (curl_ftp_no_epsv)
312
curl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);
313
314
+#ifdef CURLOPT_USE_SSL
315
+ if (curl_ssl_try)
316
+ curl_easy_setopt(result, CURLOPT_USE_SSL, CURLUSESSL_TRY);
317
+#endif
318
+
319
if (curl_http_proxy) {
320
curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);
321
curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
http.h
+9
@@ -42,6 +42,15 @@
42
#define NO_CURL_IOCTL
43
#endif
44
45
+/*
46
+ * CURLOPT_USE_SSL was known as CURLOPT_FTP_SSL up to 7.16.4,
47
+ * and the constants were known as CURLFTPSSL_*
48
+*/
49
+#if !defined(CURLOPT_USE_SSL) && defined(CURLOPT_FTP_SSL)
50
+#define CURLOPT_USE_SSL CURLOPT_FTP_SSL
51
+#define CURLUSESSL_TRY CURLFTPSSL_TRY
52
+#endif
53
+
54
struct slot_results {
55
CURLcode curl_result;
56
long http_code;