【发布时间】:2020-10-28 18:51:59
【问题描述】:
我正在尝试使用 ftplib 与 FTP 服务器建立连接。 我收到了两个文件,一个扩展名为 .crt 的证书和一个 PEM 格式的证书(RSA KEY + 证书)。
我正在使用 PEM 格式的证书通过以下代码创建上下文:
import ssl
from ftplib import FTP_TLS
ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
ssl_context.load_cert_chain('./certificate3')
ftps = FTP_TLS(context = ssl_context)
ftps.connect(host, porta)
ftps.login(user = user, passwd = pwd)
ftps.prot_p()
ftps.nlst()
如果我删除最后一个命令 (nlst),我会收到响应:'230 Logged on'。
因此,当我尝试使用 nlst() 命令提取 FTP 中的文档列表时,我收到一条错误消息:
TimeoutError: [WinError 10060] A connection attempt failed because the connected component did not respond
correctly after a period of time or the established connection has failed
because the connected host did not respond
有谁知道出了什么问题以及如何修复代码以建立连接?
【问题讨论】:
-
您能否使用与您的 Python 代码在同一台机器上运行的任何 GUI/命令行 FTP 客户端获取启用了 SSL 的目录内容?