Skip to content

Commit 59fdf0f

Browse files
njsmithvstinner
authored andcommitted
Add a test for bad IDNA in ssl server_hostname (#1997)
See discussion: #1992 (comment)
1 parent ef8320c commit 59fdf0f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Lib/test/test_ssl.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,6 +1393,16 @@ def test_subclass(self):
13931393
# For compatibility
13941394
self.assertEqual(cm.exception.errno, ssl.SSL_ERROR_WANT_READ)
13951395

1396+
def test_bad_idna_in_server_hostname(self):
1397+
# Note: this test is testing some code that probably shouldn't exist
1398+
# in the first place, so if it starts failing at some point because
1399+
# you made the ssl module stop doing IDNA decoding then please feel
1400+
# free to remove it. The test was mainly added because this case used
1401+
# to cause memory corruption (see bpo-30594).
1402+
ctx = ssl.create_default_context()
1403+
with self.assertRaises(UnicodeError):
1404+
ctx.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(),
1405+
server_hostname="xn--.com")
13961406

13971407
class MemoryBIOTests(unittest.TestCase):
13981408

0 commit comments

Comments
 (0)