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 51769 8fe7c0e1df1e
parent 51768 57f0b86611c7
child 51770 832a1aeb576f
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: