Python FTP TLS 不工作
Python FTP TLS not working
我正在尝试设置 FTP TLS 传输。我有用于 strict 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
这个错误发生在 retrlines 行。它说错误在 ssl.py at do_handshake self._sslobj.do_handshake()
.
我已经验证了与 WinSCP
的连接,并且协议是 TLS1.2
。
有什么想法吗?
好吧,问题原来是供应商只允许从特定机器访问。一旦我在正确的机器上尝试了脚本,它就成功了。
我正在尝试设置 FTP TLS 传输。我有用于 strict 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
这个错误发生在 retrlines 行。它说错误在 ssl.py at do_handshake self._sslobj.do_handshake()
.
我已经验证了与 WinSCP
的连接,并且协议是 TLS1.2
。
有什么想法吗?
好吧,问题原来是供应商只允许从特定机器访问。一旦我在正确的机器上尝试了脚本,它就成功了。