Skip to content

Commit

Permalink
imap-send.c: set CURLOPT_USE_SSL to CURLUSESSL_TRY
Browse files Browse the repository at this point in the history
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 <mackyle@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Kyle J. McKay authored and Junio C Hamano committed Jan 6, 2015
1 parent d47e55d commit 230c09c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions imap-send.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 230c09c

Please sign in to comment.