概述
*get* '150 Here comes the directory listing.\r\n' *resP* '150 Here comes the directory listing.' *get* '522 SSL connection Failed; session reuse required: see require_ssl_reuse option in vsftpd.conf man page\r\n' *resP* '522 SSL connection Failed; session reuse required: see require_ssl_reuse option in vsftpd.conf man page' Traceback (most recent call last): File "C:\temp\download.py",line 29,in <module> files = ftps.dir() File "C:\Python27\lib\ftplib.py",line 522,in dir self.retrlines(cmd,func) File "C:\Python27\lib\ftplib.py",line 725,in retrlines return self.voidresp() File "C:\Python27\lib\ftplib.py",line 224,in voidresp resp = self.getresp() File "C:\Python27\lib\ftplib.py",line 219,in getresp raise error_perm,resp ftplib.error_perm: 522 SSL connection Failed; session reuse required: see requir e_ssl_reuse option in vsftpd.conf man page
这是代码:
from ftplib import FTP_TLS import os import socket host = 'example.com' port = 34567 user = 'user1' passwd = 'pass123' acct = 'Normal' ftps = FTP_TLS() ftps.set_debuglevel(2) ftps.connect(host,port) print(ftps.getwelcome()) print(ftps.sock) ftps.auth() ftps.login(user,passwd,acct) ftps.set_pasv(True) ftps.prot_p() print('Current directory:') print(ftps.pwd()) files = ftps.dir() ftps.quit()
我想安全地这样做,因此使用FTP over TLS Explicit.我有一个想法,我可能需要操作FTPLib引用的Socket类中的一些设置.不可能更改服务器上的设置.我已经使用FileZilla客户端成功测试了服务器,旧版本的WinSCP引发了同样的错误 – 尽管升级到最新版本修复了它.
有任何想法吗?
class MyFTP_TLS(ftplib.FTP_TLS): """Explicit FTPS,with shared TLS session""" def ntransfercmd(self,cmd,rest=None): conn,size = ftplib.FTP.ntransfercmd(self,rest) if self._prot_p: conn = self.context.wrap_socket(conn,server_hostname=self.host,session=self.sock.session) # this is the fix return conn,size
总结
以上是编程之家为你收集整理的python – FTPES – 需要会话重用全部内容,希望文章能够帮你解决python – FTPES – 需要会话重用所遇到的程序开发问题。
如果您也喜欢它,动动您的小指点个赞吧