From d47e55da92932eecb58d01a7d925efa36f30087d Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Tue, 6 Jan 2015 03:00:55 -0800 Subject: [PATCH 1/2] imap-send.c: support GIT_CURL_VERBOSE When using git-imap-send to send via cURL, support setting the GIT_CURL_VERBOSE environment variable to enable cURL's verbose mode. The existing http.c code already supports this and does it by simply checking to see whether or not the environment variable exists -- it does not examine the value at all. For consistency, enable CURLOPT_VERBOSE when GIT_CURL_VERBOSE is set by using the exact same test that http.c does. Signed-off-by: Kyle J. McKay Signed-off-by: Junio C Hamano --- imap-send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imap-send.c b/imap-send.c index 4dfe4c25d..060df834c 100644 --- a/imap-send.c +++ b/imap-send.c @@ -1431,7 +1431,7 @@ static CURL *setup_curl(struct imap_server_conf *srvc) curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); - if (0 < verbosity) + if (0 < verbosity || getenv("GIT_CURL_VERBOSE")) curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); return curl; From 230c09c06a7300870f3915c54eff7d9335850a4a Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Tue, 6 Jan 2015 03:20:37 -0800 Subject: [PATCH 2/2] imap-send.c: set CURLOPT_USE_SSL to CURLUSESSL_TRY According to the cURL documentation for the CURLOPT_USE_SSL option, it is only used with plain text protocols that get upgraded to SSL using the STARTTLS command. The server.use_ssl variable is only set when we are using a protocol that is already SSL/TLS (i.e. imaps), so setting CURLOPT_USE_SSL when the server.use_ssl variable is set has no effect whatsoever. Instead, set CURLOPT_USE_SSL to CURLUSESSL_TRY when the server.use_ssl variable is NOT set so that cURL will attempt to upgrade the plain text connection to SSL/TLS using STARTTLS in that case. This much more closely matches the behavior of the non-cURL code path. Signed-off-by: Kyle J. McKay Signed-off-by: Junio C Hamano --- imap-send.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imap-send.c b/imap-send.c index 060df834c..d69887da5 100644 --- a/imap-send.c +++ b/imap-send.c @@ -1421,8 +1421,8 @@ static CURL *setup_curl(struct imap_server_conf *srvc) strbuf_release(&auth); } - if (server.use_ssl) - curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL); + if (!server.use_ssl) + curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_TRY); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, server.ssl_verify); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, server.ssl_verify);