mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Issue #19422: Explicitly disallow non-SOCK_STREAM sockets in the ssl module, rather than silently let them emit clear text data.
This commit is contained in:
commit
e6d2f159fc
4 changed files with 33 additions and 8 deletions
|
@ -632,6 +632,17 @@ class BasicSocketTests(unittest.TestCase):
|
|||
self.assertEqual(ssl.Purpose.CLIENT_AUTH.oid,
|
||||
'1.3.6.1.5.5.7.3.2')
|
||||
|
||||
def test_unsupported_dtls(self):
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
self.addCleanup(s.close)
|
||||
with self.assertRaises(NotImplementedError) as cx:
|
||||
ssl.wrap_socket(s, cert_reqs=ssl.CERT_NONE)
|
||||
self.assertEqual(str(cx.exception), "only stream sockets are supported")
|
||||
ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
||||
with self.assertRaises(NotImplementedError) as cx:
|
||||
ctx.wrap_socket(s)
|
||||
self.assertEqual(str(cx.exception), "only stream sockets are supported")
|
||||
|
||||
|
||||
class ContextTests(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue