FTPS ( FTP over SSL) Problem with Python's builtin SSL
k.robert at gmx.de
Sat Jun 5 00:15:10 CEST 2004
I need to run FTP over SSL from windows (not shitty sftp via ssh etc!)
as explained on
http://www.ford-hutchinson.com/~fh-1-pfh/ftps-ext.html (good variant
3: FTP_TLS )
I tried to learn from M2Crypto's ftpslib.py (uses OpenSSL - not
Pythons SSL) and made a wrapper for ftplib.FTP using Pythons SSL.
I wrap the cmd socket like:
ssl = socket.ssl(self.sock, self.key_file, self.cert_file)
self.sock = httplib.FakeSocket(self.sock, ssl)
self.file = self.sock.makefile('rb')
Everything works ok, if I don't SSL the data port connection, but only
If I SSL the data port connection too, it almosts work, but ...
wrap the data connection with SSL:
ssl = socket.ssl(conn, self.key_file, self.cert_file)
conn = httplib.FakeSocket(conn, ssl)
than in retrbinary it hangs endless in the last 'return
self.voidresp()'. all data of the retrieved file is already correctly
in my basket! The ftp server just won't send the final '226 Transfer
complete.' on the cmd socket. Why?
def retrbinary(self, cmd, callback, blocksize=8192, rest=None):
conn = self.transfercmd(cmd, rest)
fp = conn.makefile('rb')
#data = conn.recv(blocksize)
data = fp.read() #blocksize)
if not data:
what could be reason?
The server is a ProFTPD 1.2.9 Server.
I debugged, that the underlying (Shared)socket of the conn object is
(If I simly omit the self.voidresp(), I have one file in the box, but
subsequent ftp communication on that connection is not anymore
Someone else has already made this FTP over Python's SSL?
More information about the Python-list