Don't try TLS with SSL connections

This commit is contained in:
Guillaume Ayoub 2013-05-01 20:24:41 +02:00
parent 0f0bddedc9
commit 45c1647a92

View File

@ -58,18 +58,19 @@ def is_authenticated(user, password):
server_is_local = (IMAP_SERVER == "localhost") server_is_local = (IMAP_SERVER == "localhost")
try: if not connection_is_secure:
connection.starttls() try:
log.LOGGER.debug("IMAP server connection changed to TLS.") connection.starttls()
connection_is_secure = True log.LOGGER.debug("IMAP server connection changed to TLS.")
except AttributeError: connection_is_secure = True
if not server_is_local: except AttributeError:
log.LOGGER.error( if not server_is_local:
"Python 3.2 or newer is required for IMAP + TLS.") log.LOGGER.error(
except (imaplib.IMAP4.error, imaplib.IMAP4.abort) as exception: "Python 3.2 or newer is required for IMAP + TLS.")
log.LOGGER.warning( except (imaplib.IMAP4.error, imaplib.IMAP4.abort) as exception:
"IMAP server at %s failed to accept TLS connection " log.LOGGER.warning(
"because of: %s" % (IMAP_SERVER, exception)) "IMAP server at %s failed to accept TLS connection "
"because of: %s" % (IMAP_SERVER, exception))
if server_is_local and not connection_is_secure: if server_is_local and not connection_is_secure:
log.LOGGER.warning( log.LOGGER.warning(