ftpslib caveat solution?

jeff jdigital2121 at yahoo.com
Sun Feb 22 04:54:58 EST 2009


The only python library that I am aware of that supports ftp + TLS is ftpslib, which is also included with M2Crypto. However, as stated in the README, there is one major caveat. Quote:
"""

The end-of-file marker for binary data transfers is sent by closing the
connection.  Many FTP servers close the TCP socket without shutting down the
TLS connection.  ftpslib attempts to avoid this by using the method in
test_ftpslib.py attached to Python bug 978833, overriding retrbinary to read
from the socket's makefile wrapper instead of the socket itself.  Although
this appears to work for the builtin socket.ssl and M2Crypto, it is
conceivable for a particular SSL implementation to still throw an exception in
this case, and, regardless, the issue is still exposed when using ntransfercmd
outside of retrbinary.  Note that if an exception is thrown in retrbinary, the
response from the last RETR will not be read, causing any future commands to
be one response behind.  This is especially troublesome if using passive FTP,
as the FTP class will be unable to parse the 227 response to future PASV
commands.

"""

Has anyone happened to figure out a more elegant solution to this? More specifically, the part about responses being
1 response behind when an exception is thrown, thus making this module unstable when working with a pasv FTP. Any
insight to solving this problem would be much appreciated.

Cheers,
Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090222/16f3bad1/attachment.html>


More information about the Python-list mailing list