]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-32947: test_ssl fixes for TLS 1.3 and OpenSSL 1.1.1 (GH-11612)
authorVictor Stinner <vstinner@redhat.com>
Wed, 29 May 2019 02:04:54 +0000 (04:04 +0200)
committerNed Deily <nad@python.org>
Wed, 29 May 2019 02:04:54 +0000 (22:04 -0400)
Backport partially commit 529525fb5a8fd9b96ab4021311a598c77588b918:
complete the previous partial backport (commit
2a4ee8aa01d61b6a9c8e9c65c211e61bdb471826.

Co-Authored-By: Christian Heimes <christian@python.org>
Lib/test/test_ssl.py
Misc/NEWS.d/next/Tests/2019-01-18-17-46-10.bpo-32947.Hk0KnM.rst [new file with mode: 0644]

index 0aeabc10f2a97fc9b172d82aa0b53f5715f23eb4..2cabfe5d0b08f8e3569ccfa9da7650be3285eb4c 100644 (file)
@@ -2029,6 +2029,16 @@ if _have_threads:
                                 sys.stdout.write(" server: read %r (%s), sending back %r (%s)...\n"
                                                  % (msg, ctype, msg.lower(), ctype))
                             self.write(msg.lower())
+                    except ConnectionResetError:
+                        # XXX: OpenSSL 1.1.1 sometimes raises ConnectionResetError
+                        # when connection is not shut down gracefully.
+                        if self.server.chatty and support.verbose:
+                            sys.stdout.write(
+                                " Connection reset by peer: {}\n".format(
+                                    self.addr)
+                            )
+                        self.close()
+                        self.running = False
                     except OSError:
                         if self.server.chatty:
                             handle_error("Test server failure:\n")
@@ -2108,6 +2118,11 @@ if _have_threads:
                     pass
                 except KeyboardInterrupt:
                     self.stop()
+                except BaseException as e:
+                    if support.verbose and self.chatty:
+                        sys.stdout.write(
+                            ' connection handling failed: ' + repr(e) + '\n')
+
             self.sock.close()
 
         def stop(self):
diff --git a/Misc/NEWS.d/next/Tests/2019-01-18-17-46-10.bpo-32947.Hk0KnM.rst b/Misc/NEWS.d/next/Tests/2019-01-18-17-46-10.bpo-32947.Hk0KnM.rst
new file mode 100644 (file)
index 0000000..f508504
--- /dev/null
@@ -0,0 +1 @@
+test_ssl fixes for TLS 1.3 and OpenSSL 1.1.1.