[PATCHv3 3/3] Check for SSL module existence and only do fingerprint check then

Sebastian Spaeth Sebastian at SSpaeth.de
Mon Sep 12 08:50:43 BST 2011


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 at SSpaeth.de>
---
 offlineimap/imaplibutil.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/offlineimap/imaplibutil.py b/offlineimap/imaplibutil.py
index 609fd4d..5c94592 100644
--- a/offlineimap/imaplibutil.py
+++ b/offlineimap/imaplibutil.py
@@ -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:
-- 
1.7.4.1





More information about the OfflineIMAP-project mailing list