diff options
| author | Antoine Pitrou <solipsis@pitrou.net> | 2013-09-29 17:50:53 (GMT) |
|---|---|---|
| committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-09-29 17:50:53 (GMT) |
| commit | 20b85557f2cc8f5f10d7d98314a3181c60553e12 (patch) | |
| tree | 80ad5b16d5f0644f096a284d0b43fedb13630b21 /Lib | |
| parent | cf892ace48721cb301d6f8d56ad8779bc13cb9de (diff) | |
| download | cpython-20b85557f2cc8f5f10d7d98314a3181c60553e12.zip cpython-20b85557f2cc8f5f10d7d98314a3181c60553e12.tar.gz cpython-20b85557f2cc8f5f10d7d98314a3181c60553e12.tar.bz2 | |
Issue #19095: SSLSocket.getpeercert() now raises ValueError when the SSL handshake hasn't been done.
Diffstat (limited to 'Lib')
| -rw-r--r-- | Lib/test/test_ssl.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 8915305..2605e68 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -1588,8 +1588,14 @@ else: context.load_cert_chain(CERTFILE) server = ThreadedEchoServer(context=context, chatty=False) with server: - s = context.wrap_socket(socket.socket()) + s = context.wrap_socket(socket.socket(), + do_handshake_on_connect=False) s.connect((HOST, server.port)) + # getpeercert() raise ValueError while the handshake isn't + # done. + with self.assertRaises(ValueError): + s.getpeercert() + s.do_handshake() cert = s.getpeercert() self.assertTrue(cert, "Can't get peer certificate.") cipher = s.cipher() |
