Giampaolo Rodola' added the comment: I've tried to work on this in the last 2 days and here is my implementation attempt. The patch in attachment provides a new FTP subclass which connects to port 21 as usual leaving control and data channels implicitly unprotected. Securing control and data channels requires user to explicitly ask for it by using the new auth_tls() and prot_p() methods as recommended by the standard RFC.
Usage example: >>> from ftplib import FTP_TLS >>> ftps = FTP_TLS('ftp.python.org') >>> ftps.auth_tls() # switch to secure control connection '234 Using authentication type TLS' >>> ftps.login() # login anonimously '230 Guest login ok, access restrictions apply.' >>> ftps.prot_p() # switch to secure data connection '200 Protection level set to P' >>> ftps.retrlines('LIST') # list directory content securely total 9 drwxr-xr-x 8 root wheel 1024 Jan 3 1994 . drwxr-xr-x 8 root wheel 1024 Jan 3 1994 .. drwxr-xr-x 2 root wheel 1024 Jan 3 1994 bin drwxr-xr-x 2 root wheel 1024 Jan 3 1994 etc d-wxrwxr-x 2 ftp wheel 1024 Sep 5 13:43 incoming drwxr-xr-x 2 root wheel 1024 Nov 17 1993 lib drwxr-xr-x 6 1094 wheel 1024 Sep 13 19:07 pub drwxr-xr-x 3 root wheel 1024 Jan 3 1994 usr -rw-r--r-- 1 root root 312 Aug 1 1994 welcome.msg '226 Transfer complete.' >>> ftps.quit() '221 Goodbye.' >>> It also provides a prot_c() method to switch back to a plain text data channel. Sorry in advance for any grammatical error I could have made in comments and docstrings. Comments are greatly appreciated. ---------- nosy: +giampaolo.rodola, janssen Added file: http://bugs.python.org/file9471/ftplib.diff __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2054> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com