mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #13721: SSLSocket.getpeercert() and SSLSocket.do_handshake() now raise an OSError with ENOTCONN, instead of an AttributeError, when the SSLSocket is not connected.
This commit is contained in:
parent
f6ca26fbff
commit
242db728e2
3 changed files with 41 additions and 12 deletions
|
@ -17,6 +17,7 @@ import asyncore
|
|||
import weakref
|
||||
import platform
|
||||
import functools
|
||||
from unittest import mock
|
||||
|
||||
ssl = support.import_module("ssl")
|
||||
|
||||
|
@ -1931,6 +1932,20 @@ else:
|
|||
self.assertIsInstance(remote, ssl.SSLSocket)
|
||||
self.assertEqual(peer, client_addr)
|
||||
|
||||
def test_getpeercert_enotconn(self):
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
||||
with context.wrap_socket(socket.socket()) as sock:
|
||||
with self.assertRaises(OSError) as cm:
|
||||
sock.getpeercert()
|
||||
self.assertEqual(cm.exception.errno, errno.ENOTCONN)
|
||||
|
||||
def test_do_handshake_enotconn(self):
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
||||
with context.wrap_socket(socket.socket()) as sock:
|
||||
with self.assertRaises(OSError) as cm:
|
||||
sock.do_handshake()
|
||||
self.assertEqual(cm.exception.errno, errno.ENOTCONN)
|
||||
|
||||
def test_default_ciphers(self):
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue