bpo-42854: Use SSL_read/write_ex() (GH-25468) · python/cpython@89d1550 · GitHub
Skip to content

Commit 89d1550

Browse files
authored
bpo-42854: Use SSL_read/write_ex() (GH-25468)
The ssl module now uses ``SSL_read_ex`` and ``SSL_write_ex`` internally. The functions support reading and writing of data larger than 2 GB. Writing zero-length data no longer fails with a protocol violation error. Signed-off-by: Christian Heimes <christian@python.org>
1 parent 49fdf11 commit 89d1550

4 files changed

Lines changed: 34 additions & 18 deletions

File tree

Doc/library/ssl.rst

Lines changed: 5 additions & 0 deletions

Lib/test/test_ssl.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,17 @@ def test_connect_ex_error(self):
11101110
)
11111111
self.assertIn(rc, errors)
11121112

1113+
def test_read_write_zero(self):
1114+
# empty reads and writes now work, bpo-42854, bpo-31711
1115+
client_context, server_context, hostname = testing_context()
1116+
server = ThreadedEchoServer(context=server_context)
1117+
with server:
1118+
with client_context.wrap_socket(socket.socket(),
1119+
server_hostname=hostname) as s:
1120+
s.connect((HOST, server.port))
1121+
self.assertEqual(s.recv(0), b"")
1122+
self.assertEqual(s.send(b""), 0)
1123+
11131124

11141125
class ContextTests(unittest.TestCase):
11151126

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The :mod:`ssl` module now uses ``SSL_read_ex`` and ``SSL_write_ex``
2+
internally. The functions support reading and writing of data larger
3+
than 2 GB. Writing zero-length data no longer fails with a protocol
4+
violation error.

Modules/_ssl.c

Lines changed: 14 additions & 18 deletions

0 commit comments

Comments
 (0)