I'm trying to setup an FTP TLS transfer. I have scripts for strict FTP and for SFTP, but this is my first exposure to TLS. My basic script:
import ftplib
import ssl
ctx = ssl._create_stdlib_context(ssl.PROTOCOL_TLSv1_2)
ftps = ftplib.FTP_TLS(context=ctx)
print (ftps.connect(myhost,21))
print(ftps.login(myusername,mypwd))
print("1")
ftps.prot_p()
print("2")
print (ftps.retrlines('LIST'))
print("3")
Error:
[WinError 10054] An existing connection was forcibly closed by the remote host
This error occurs at the retrlines line. It says the error is in ssl.py at do_handshake self._sslobj.do_handshake()
.
I've already verified the connection with WinSCP
, and that the protocol is TLS1.2
.
Any ideas?