CERT_NONE + gmail = no certificate received?

Anonymous swell.k at gmail.com
Mon Jan 17 13:58:18 GMT 2011

I have a gmail account that previously worked on 9239a2d revision.
Now, as of v6.3.2-rc1 it no longer works

  $ offlineimap -u TTY.TTYUI
   OfflineIMAP 6.3.1
  Copyright (C) 2002 - 2009 John Goerzen <jgoerzen at complete.org>
  This software comes with ABSOLUTELY NO WARRANTY; see the file
  COPYING for details.  This is free software, and you are welcome
  to distribute it under the conditions laid out in COPYING.
  Account sync blah:
   ***** Processing account blah
   Copying folder structure from Gmail to Maildir
   Establishing connection to imap.gmail.com:993.
   WARNING: Error occured attempting to sync account blah: SSL Certificate host name mismatch: no certificate received
   ***** Finished processing account blah

which is

  [Repository blah|remote]
  type = Gmail
  remoteuser = blah

Not sure why it doesn't

  $ python
  Python 2.7.1 (r271:86832, Dec 18 2010, 19:55:45)
  [GCC 4.5.2 20101125 (prerelease)] on freebsd9
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import ssl; ssl.get_server_certificate(('imap.gmail.com',993))
  '-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----\n'

but below hack makes it work again

diff --git a/offlineimap/imaplibutil.py b/offlineimap/imaplibutil.py
index ba6a5bb..0b697ad 100644
--- a/offlineimap/imaplibutil.py
+++ b/offlineimap/imaplibutil.py
@@ -152,8 +152,10 @@ class WrappedIMAP4_SSL(IMAP4_SSL):
         Returns error message if any problems are found and None on success.
-        if not cert:
+        if not cert and not type(cert) is dict:
             return ('no certificate received')
+        else:
+            return
         dnsname = hostname.lower()
         for s in cert.get('subject', []):
             key, value = s[0]

More information about the OfflineIMAP-project mailing list