summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ssl.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-06-03 20:12:31 (GMT)
committerGitHub <noreply@github.com>2021-06-03 20:12:31 (GMT)
commit5c2191df9a21a3b3d49dd0711b8d2b92591ce82b (patch)
treebc4cfb5221d166785e09394782eb6bfca9bf00f4 /Lib/test/test_ssl.py
parentf3491242e41933aa9529add7102edb68b80a25e9 (diff)
downloadcpython-5c2191df9a21a3b3d49dd0711b8d2b92591ce82b.zip
cpython-5c2191df9a21a3b3d49dd0711b8d2b92591ce82b.tar.gz
cpython-5c2191df9a21a3b3d49dd0711b8d2b92591ce82b.tar.bz2
bpo-43921: Cleanup test_ssl.test_wrong_cert_tls13() (GH-26520)
Don't catch OSError, and check the SSLError message.
Diffstat (limited to 'Lib/test/test_ssl.py')
-rw-r--r--Lib/test/test_ssl.py17
1 files changed, 5 insertions, 12 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index 85ad8ae..fdf5f19 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -3192,23 +3192,16 @@ class ThreadedTests(unittest.TestCase):
client_context.wrap_socket(socket.socket(),
server_hostname=hostname,
suppress_ragged_eofs=False) as s:
- # TLS 1.3 perform client cert exchange after handshake
s.connect((HOST, server.port))
- try:
+ with self.assertRaisesRegex(
+ ssl.SSLError,
+ 'alert unknown ca|EOF occurred'
+ ):
+ # TLS 1.3 perform client cert exchange after handshake
s.write(b'data')
s.read(1000)
s.write(b'should have failed already')
s.read(1000)
- except ssl.SSLError as e:
- if support.verbose:
- sys.stdout.write("\nSSLError is %r\n" % e)
- except OSError as e:
- if e.errno != errno.ECONNRESET:
- raise
- if support.verbose:
- sys.stdout.write("\nsocket.error is %r\n" % e)
- else:
- self.fail("Use of invalid cert should have failed!")
def test_rude_shutdown(self):
"""A brutal shutdown of an SSL server should raise an OSError