Skip to content

Commit cabe916

Browse files
miss-islingtontiran
andcommitted
[3.6] bpo-34391: Fix ftplib test for TLS 1.3 (GH-8787) (#8790)
Read from data socket to avoid "[SSL] shutdown while in init" exception during shutdown of the dummy server. Signed-off-by: Christian Heimes <christian@python.org> <!-- issue-number: [bpo-34391](https://www.bugs.python.org/issue34391) --> https://bugs.python.org/issue34391 <!-- /issue-number --> (cherry picked from commit 1590c39) Co-authored-by: Christian Heimes <christian@python.org>
1 parent b14ab44 commit cabe916

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

Lib/test/test_ftplib.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,18 +876,23 @@ def test_data_connection(self):
876876
# clear text
877877
with self.client.transfercmd('list') as sock:
878878
self.assertNotIsInstance(sock, ssl.SSLSocket)
879+
self.assertEqual(sock.recv(1024), LIST_DATA.encode('ascii'))
879880
self.assertEqual(self.client.voidresp(), "226 transfer complete")
880881

881882
# secured, after PROT P
882883
self.client.prot_p()
883884
with self.client.transfercmd('list') as sock:
884885
self.assertIsInstance(sock, ssl.SSLSocket)
886+
# consume from SSL socket to finalize handshake and avoid
887+
# "SSLError [SSL] shutdown while in init"
888+
self.assertEqual(sock.recv(1024), LIST_DATA.encode('ascii'))
885889
self.assertEqual(self.client.voidresp(), "226 transfer complete")
886890

887891
# PROT C is issued, the connection must be in cleartext again
888892
self.client.prot_c()
889893
with self.client.transfercmd('list') as sock:
890894
self.assertNotIsInstance(sock, ssl.SSLSocket)
895+
self.assertEqual(sock.recv(1024), LIST_DATA.encode('ascii'))
891896
self.assertEqual(self.client.voidresp(), "226 transfer complete")
892897

893898
def test_login(self):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix ftplib test for TLS 1.3 by reading from data socket.

0 commit comments

Comments
 (0)