Skip to content

Commit 870247a

Browse files
miss-islingtontiran
andcommitted
[3.7] bpo-34391: Fix ftplib test for TLS 1.3 (GH-8787) (GH-8789)
Read from data socket to avoid "[SSL] shutdown while in init" exception during shutdown of the dummy server. Signed-off-by: Christian Heimes <[email protected]> <!-- 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 <[email protected]>
1 parent bf8e9d1 commit 870247a

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
@@ -880,18 +880,23 @@ def test_data_connection(self):
880880
# clear text
881881
with self.client.transfercmd('list') as sock:
882882
self.assertNotIsInstance(sock, ssl.SSLSocket)
883+
self.assertEqual(sock.recv(1024), LIST_DATA.encode('ascii'))
883884
self.assertEqual(self.client.voidresp(), "226 transfer complete")
884885

885886
# secured, after PROT P
886887
self.client.prot_p()
887888
with self.client.transfercmd('list') as sock:
888889
self.assertIsInstance(sock, ssl.SSLSocket)
890+
# consume from SSL socket to finalize handshake and avoid
891+
# "SSLError [SSL] shutdown while in init"
892+
self.assertEqual(sock.recv(1024), LIST_DATA.encode('ascii'))
889893
self.assertEqual(self.client.voidresp(), "226 transfer complete")
890894

891895
# PROT C is issued, the connection must be in cleartext again
892896
self.client.prot_c()
893897
with self.client.transfercmd('list') as sock:
894898
self.assertNotIsInstance(sock, ssl.SSLSocket)
899+
self.assertEqual(sock.recv(1024), LIST_DATA.encode('ascii'))
895900
self.assertEqual(self.client.voidresp(), "226 transfer complete")
896901

897902
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)