Python FTP TLS无法正常工作

时间:2017-08-17 18:29:56

标签: python ssl ftp ftplib

我正在尝试设置FTP TLS传输。我有严格FTP和SFTP的脚本,但这是我第一次接触TLS。我的基本脚本:

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

错误:

[WinError 10054] An existing connection was forcibly closed by the remote host

此错误发生在后退线。它说错误是在do_handshake self._sslobj.do_handshake()的ssl.py中。

我已经验证了与WinSCP的关联,并且协议是TLS1.2

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

好吧,问题是供应商只允许从特定机器访问。一旦我在正确的机器上尝试了脚本,它就可以了。