dummysmtpd: fix EOF handling on newer versions of OpenSSL
authorRaphaël Gomès <rgomes@octobus.net>
Mon, 22 Jul 2024 14:42:54 +0200
changeset 51698 8f0b0df79039
parent 51697 4f4f65c67729
child 51699 bd1483fd7088
dummysmtpd: fix EOF handling on newer versions of OpenSSL Explanations inline.
tests/dummysmtpd.py
tests/test-patchbomb-tls.t
--- a/tests/dummysmtpd.py	Mon Jul 22 14:19:12 2024 +0200
+++ b/tests/dummysmtpd.py	Mon Jul 22 14:42:54 2024 +0200
@@ -31,8 +31,15 @@
 def mocksmtpserversession(conn, addr):
     conn.send(b'220 smtp.example.com ESMTP\r\n')
 
-    line = conn.recv(1024)
+    try:
+        # Newer versions of OpenSSL raise on EOF
+        line = conn.recv(1024)
+    except ssl.SSLError:
+        log('no hello: EOF\n')
+        return
+
     if not line.lower().startswith(b'ehlo '):
+        # Older versions of OpenSSl don't raise
         log('no hello: %s\n' % line)
         return
 
--- a/tests/test-patchbomb-tls.t	Mon Jul 22 14:19:12 2024 +0200
+++ b/tests/test-patchbomb-tls.t	Mon Jul 22 14:42:54 2024 +0200
@@ -98,7 +98,7 @@
   $ wait_log "no hello:"
   $ cat ../log
   connection from * (glob)
-  no hello: b''
+  no hello: (b''|EOF) (re)
   $ : > ../log
 
 With global certificates: