Skip to content

Commit 4bc444e

Browse files
modaxgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5234b41 commit 4bc444e

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

Documentation/config.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,14 @@ http.sslCAPath::
14471447
with when fetching or pushing over HTTPS. Can be overridden
14481448
by the 'GIT_SSL_CAPATH' environment variable.
14491449

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+
14501458
http.maxRequests::
14511459
How many HTTP requests to launch in parallel. Can be overridden
14521460
by the 'GIT_HTTP_MAX_REQUESTS' environment variable. Default is 5.

http.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ static CURL *curl_default;
3030
char curl_errorstr[CURL_ERROR_SIZE];
3131

3232
static int curl_ssl_verify = -1;
33+
static int curl_ssl_try;
3334
static const char *ssl_cert;
3435
#if LIBCURL_VERSION_NUM >= 0x070903
3536
static const char *ssl_key;
@@ -162,6 +163,10 @@ static int http_options(const char *var, const char *value, void *cb)
162163
ssl_cert_password_required = 1;
163164
return 0;
164165
}
166+
if (!strcmp("http.ssltry", var)) {
167+
curl_ssl_try = git_config_bool(var, value);
168+
return 0;
169+
}
165170
if (!strcmp("http.minsessions", var)) {
166171
min_curl_sessions = git_config_int(var, value);
167172
#ifndef USE_CURL_MULTI
@@ -306,6 +311,11 @@ static CURL *get_curl_handle(void)
306311
if (curl_ftp_no_epsv)
307312
curl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);
308313

314+
#ifdef CURLOPT_USE_SSL
315+
if (curl_ssl_try)
316+
curl_easy_setopt(result, CURLOPT_USE_SSL, CURLUSESSL_TRY);
317+
#endif
318+
309319
if (curl_http_proxy) {
310320
curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);
311321
curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY);

http.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@
4242
#define NO_CURL_IOCTL
4343
#endif
4444

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+
4554
struct slot_results {
4655
CURLcode curl_result;
4756
long http_code;

0 commit comments

Comments
 (0)