2

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?

Md. Rezwanul Haque
  • 2,882
  • 7
  • 28
  • 45
Mike
  • 632
  • 2
  • 7
  • 17

1 Answers1

0

Well, the issue turned out to be that the vendor was only allowing access from a specific machine. Once I tried the script on the correct machine, it worked.

Mike
  • 632
  • 2
  • 7
  • 17