gpt4 book ai didi

Python FTP TLS 不工作

转载 作者:太空宇宙 更新时间:2023-11-03 13:06:02 27 4
gpt4 key购买 nike

我正在尝试设置 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

此错误发生在 retrlines 行。它说错误在 ssl.py 中的 do_handshake self._sslobj.do_handshake()

我已经验证了与 WinSCP 的连接,并且协议(protocol)是 TLS1.2

有什么想法吗?

最佳答案

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

关于Python FTP TLS 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45742599/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com