Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python ftplib-504安全机制&x27;TLS&x27;未实施_Python_Ssl_Ftp_Ftplib - Fatal编程技术网

Python ftplib-504安全机制&x27;TLS&x27;未实施

Python ftplib-504安全机制&x27;TLS&x27;未实施,python,ssl,ftp,ftplib,Python,Ssl,Ftp,Ftplib,我正在尝试使用ftplib连接到安全FTP,但由于某些原因,它无法工作(尝试连接到www.sharefile.com FTP。那里显示使用此地址:company.sharefileftp.com) 我正在尝试这种方法(): 但是它给了我这个错误(当调用这一行时ftps.login('testuser','testpass')): 错误\u perm回溯(最近一次调用) 在() ---->ftps.login('user','pass') /登录中的usr/lib/python2.7/ftplib

我正在尝试使用
ftplib
连接到安全FTP,但由于某些原因,它无法工作(尝试连接到www.sharefile.com FTP。那里显示使用此地址:company.sharefileftp.com)

我正在尝试这种方法():

但是它给了我这个错误(当调用这一行时
ftps.login('testuser','testpass')
):

错误\u perm回溯(最近一次调用)
在()
---->ftps.login('user','pass')
/登录中的usr/lib/python2.7/ftplib.pyc(self、user、passwd、acct、secure)
650 def登录(self,user='',passwd='',acct='',secure=True):
651如果安全且不存在(self.sock、ssl.SSLSocket):
-->652 self.auth()
653返回FTP.login(self、user、passwd、acct)
654
/auth(self)中的usr/lib/python2.7/ftplib.pyc
658提升值错误(“已在使用TLS”)
659如果self.ssl_version==ssl.PROTOCOL_TLSv1:
-->660 resp=self.voidcmd('AUTH TLS'))
661其他:
662 resp=self.voidcmd('AUTH SSL'))
/voidcmd(self,cmd)中的usr/lib/python2.7/ftplib.pyc
252“发送命令并期望响应以“2”开头。”
253自我保护指令(指令指令)
-->254返回self.voidresp()
255
256 def发送端口(自身、主机、端口):
/usr/lib/python2.7/ftplib.pyc-in-voidresp(self)
227 def voidresp(自身):
228“预期响应以“2”开头。”
-->229 resp=self.getresp()
230如果响应[:1]!='2':
231分别提出错误和答复
/getresp(self)中的usr/lib/python2.7/ftplib.pyc
222上升错误温度,分别
223如果c=='5':
-->224分别引发错误
225上升误差_proto,resp
226
错误\u perm:504未实现安全机制“TLS”。
p.S.但我可以使用FTP连接(不安全):

>>从ftplib导入FTP
>>>ftp=ftp('company.sharefileftp.com')#连接到主机,默认端口
>>>ftp.login('user','pass')#用户匿名,passwd匿名@

服务器根本不支持TLS,既不支持旧的“AUTH SSL”,也不支持新的“AUTH TLS”。此问题与python无关,如下telnet测试所示:

$telnet company.sharefileftp.com 21
Trying 54.194.108.219...
Connected to company.sharefileftp.com.
Escape character is '^]'.
220 ftp-eu-1.sharefileftp.com FTP Server Ready
AUTH TLS
504 Security mechanism 'TLS' not implemented.
AUTH SSL
504 Security mechanism 'SSL' not implemented.
QUIT
221-Sent: 142 bytes   Rcvd: 26 bytes   Time: 15s
221 ftp-eu-1.sharefileftp.com session ended.
Connection closed by foreign host.
但它确实支持(旧的、从未标准化的)隐式TLS:

$ openssl s_client -connect company.sharefileftp.com:990
...
SSL-Session:
    Protocol  : TLSv1
   Cipher    : RC4-SHA
...
220 ftp-eu-1.sharefileftp.com FTP Server Ready (SSL)

您使用的是显式TLS/SSL(通常推荐的模式)

似乎sharefile.com只支持隐式TLS/SSL(这是非常不寻常的)

相反,ftplib似乎不支持开箱即用的隐式TLS/SSL

不过你可以把它修好。请参阅以下内容的答案:

$ openssl s_client -connect company.sharefileftp.com:990
...
SSL-Session:
    Protocol  : TLSv1
   Cipher    : RC4-SHA
...
220 ftp-eu-1.sharefileftp.com FTP Server Ready (SSL)