我正在尝试使用ftps将文件上载到我们的ftp服务器。登录很简单,可以工作:
from M2Crypto import ftpslib
ftp = ftpslib.FTP_TLS()
ftp.connect(host)
ftp.login(username, password)
以及降序到目录
for dir in directory:
ftp.cwd(dir)
但是,在尝试检索目录内容时:
if directory_name not in ftp.nlst():
ftp.mkd(directory_name)
我得到522个错误:
File "/usr/lib/python2.5/ftplib.py", line 459, in nlst
self.retrlines(cmd, files.append)
File "/usr/lib/python2.5/ftplib.py", line 407, in retrlines
conn = self.transfercmd(cmd)
File "/usr/lib/python2.5/ftplib.py", line 356, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "/var/lib/python-support/python2.5/M2Crypto/ftpslib.py", line 86, in ntransfercmd
conn, size = FTP.ntransfercmd(self, cmd, rest)
File "/usr/lib/python2.5/ftplib.py", line 327, in ntransfercmd
resp = self.sendcmd(cmd)
File "/usr/lib/python2.5/ftplib.py", line 241, in sendcmd
return self.getresp()
File "/usr/lib/python2.5/ftplib.py", line 216, in getresp
raise error_perm, resp
ftplib.error_perm: 522 Data connections must be encrypted.
似乎TLS仅用于握手,而不用于传输。
它有一种安全传输的方法(我想使用
storbinary()
)使用M2Crypto?如果没有,还有其他的选择吗?