diff roundup/mailgw.py @ 6582:3e8f2104753b

issue2551186 - replace socket.sslerror in mailgw.py. roundup/mailgw.py: replaced socket.sslerror with anypy/ssl_.SSLError also looks like a socket.sslerror was removed from pops handling. added it back using method above. roundupanypy/ssl_.py: defines replacement SSLError suitable for python2 or 3 tested by running nc -lp 995 or 993 (pop3s/imaps) and sending gibberish when mailgw connects. This generates a bad version number SSLError. I need to get my imap and pop mock servers included for testing at some point, but I am not sure how to make them bind to the right port as they are priv ports.
author John Rouillard <rouilj@ieee.org>
date Tue, 04 Jan 2022 18:39:40 -0500
parents 14c9284a8bad
children 408fd477761f
line wrap: on
line diff
--- a/roundup/mailgw.py	Tue Jan 04 16:31:04 2022 -0500
+++ b/roundup/mailgw.py	Tue Jan 04 18:39:40 2022 -0500
@@ -112,6 +112,7 @@
 from roundup.hyperdb import iter_roles
 from roundup.anypy.strings import StringIO, b2s, u2s
 import roundup.anypy.random_ as random_
+import roundup.anypy.ssl_ as ssl_
 
 try:
     import gpg, gpg.core, gpg.constants, gpg.constants.sigsum
@@ -1373,7 +1374,7 @@
             else:
                 self.logger.debug('Trying server %r without ssl' % server)
                 server = imaplib.IMAP4(server)
-        except (imaplib.IMAP4.error, socket.error, socket.sslerror):
+        except (imaplib.IMAP4.error, socket.error, ssl_.SSLError):
             self.logger.exception('IMAP server error')
             return 1
 
@@ -1415,7 +1416,7 @@
         finally:
             try:
                 server.expunge()
-            except (imaplib.IMAP4.error, socket.error, socket.sslerror):
+            except (imaplib.IMAP4.error, socket.error, ssl_.SSLError):
                 pass
             server.logout()
 
@@ -1461,7 +1462,7 @@
             else:
                 klass = poplib.POP3
             server = klass(server)
-        except socket.error:
+        except (socket.error, ssl_.SSLError):
             self.logger.exception('POP server error')
             return 1
         if apop:

Roundup Issue Tracker: http://roundup-tracker.org/