Check for SSL module existence and only do fingerprint check then

Python 2.5 has no ssl module, and we can therefor not get the server
certificate for fingerprint verification. Add a check that disables
fingerprint verification for python 2.5.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Sebastian Spaeth 2011-09-12 09:50:43 +02:00 committed by Nicolas Sebrecht
parent eafea0c880
commit bc10e05600
1 changed files with 2 additions and 1 deletions

View File

@ -147,7 +147,8 @@ class WrappedIMAP4_SSL(UsefulIMAPMixIn, IMAP4_SSL):
def open(self, host=None, port=None):
super(WrappedIMAP4_SSL, self).open(host, port)
if self._fingerprint or not self.ca_certs:
if (self._fingerprint or not self.ca_certs) and\
'ssl' in locals(): # <--disable for python 2.5
# compare fingerprints
fingerprint = sha1(self.sock.getpeercert(True)).hexdigest()
if fingerprint != self._fingerprint: