Open vatruica opened 8 years ago
Imported FTP_TLS from ftplib - on line 20 :
from ftplib import FTP, FTP_TLS, error_perm
Used the FTP_TLS method instead of FTP on line 132 :
self._ftp = c = FTP_TLS(self.server, self.username, self.password)
Getting a SSL error :
ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:581)
I think its more due to the fact that I'm using a self-signed certificate. The library (https://docs.python.org/2/library/ftplib.html) doesn't give too much info on certificates and just accepting them. Going to look further into this.
@victor1tnet, I got FTP over explicit TLS working, thanks to your suggestions as a starting point.
On line 20, you no longer need to import FTP, just FTP_TLS (not that this caused the error):
from ftplib import FTP_TLS, error_perm
Additionally, on line 132, I ended up with these lines (before the clocksync()
method is called again):
c = FTP_TLS(self.server)
c.login(self.username, self.password) # login anonymously before securing control channel
c.prot_p() #Switch to secure data connection
self._ftp = c
There may be a more pythonic way of doing that, but I think the crucial piece in there is that third line (the c.prot_p()
command), so it switches to using the secure data connection.
Additionally, for anybody connecting to a Microsoft FTP server, you may need to override Python's stor_binary
method. See this article for details. (fwiw, I implemented that override without issue on 2.7.11, not 3, as that link references).
Not sure if an issue or a feature request ...
I've tried using FTPS:// instead of FTP:// but force adds an FTP:// in front so it's being recognized as the hostname.
I'm not seeing any TLS/SSL/FTPS reference in the code, so by any chance, will this be supporting FTPS ? Or a quick suggestion on how to add support for that?
Thx