mirror of
https://github.com/curl/curl.git
synced 2025-01-30 14:22:33 +08:00
imap: Added support for the STARTTLS capability (Part Three)
Added honoring of the tls_supported flag when starting a TLS upgrade rather than unconditionally attempting it. If the use_ssl flag is set to CURLUSESSL_TRY and the server doesn't support TLS upgrades then the connection will continue to authenticate. If this flag is set to CURLUSESSL_ALL then the connection will complete with a failure as it did previously.
This commit is contained in:
parent
b333504327
commit
b50ce1e5ba
13
lib/imap.c
13
lib/imap.c
@ -709,15 +709,24 @@ static CURLcode imap_state_capability_resp(struct connectdata *conn,
|
|||||||
{
|
{
|
||||||
CURLcode result = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
|
struct imap_conn *imapc = &conn->proto.imapc;
|
||||||
|
|
||||||
(void)instate; /* no use for this yet */
|
(void)instate; /* no use for this yet */
|
||||||
|
|
||||||
if(imapcode != 'O')
|
if(imapcode != 'O')
|
||||||
result = imap_state_login(conn);
|
result = imap_state_login(conn);
|
||||||
else if(data->set.use_ssl && !conn->ssl[FIRSTSOCKET].use) {
|
else if(data->set.use_ssl && !conn->ssl[FIRSTSOCKET].use) {
|
||||||
/* We don't have a SSL/TLS connection yet, but SSL is requested. Switch
|
/* We don't have a SSL/TLS connection yet, but SSL is requested */
|
||||||
to TLS connection now */
|
if(imapc->tls_supported)
|
||||||
|
/* Switch to TLS connection now */
|
||||||
result = imap_state_starttls(conn);
|
result = imap_state_starttls(conn);
|
||||||
|
else if(data->set.use_ssl == CURLUSESSL_TRY)
|
||||||
|
/* Fallback and carry on with authentication */
|
||||||
|
result = imap_authenticate(conn);
|
||||||
|
else {
|
||||||
|
failf(data, "STARTTLS not supported.");
|
||||||
|
result = CURLE_USE_SSL_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
result = imap_authenticate(conn);
|
result = imap_authenticate(conn);
|
||||||
|
Loading…
Reference in New Issue
Block a user