I use FTPS
there are several variant of FTPS, check this on eg wikipedia.
the implicit version does work but I do not use it is production (as a prject was aborted)
untill now I did not need the keys directly, but it should be fairly easy to do that.
henk-jan
sorry for my late reaction, slipped thru my mind (holidays etc).
in a communication script you can subclass the class ftpis in communication.py
you only need the connect method.
best is probably to copy the existing connect() method in communication.py,
and introduce the private keys there.
you will need python 2.7
check out the python doc (ftplib)
let me know if I can help.
henk-jan ebbers
No problem, I hope you enjoyed your holidays. I'll try it your way, but in the meantime, here's what we've done...
I know modifiying Communication.py is not a good idea (for future releases & upgrades) - let's say it's quick & dirty, but it works (very well) :-)
import ftplib27 #(ftplib27 is the ftplib from Python 2.7)
class ftps(ftp):
def connect(self):
botslib.settimeout(botsglobal.ini.getint('settings','ftptimeout',10))
if not hasattr(ftplib27,'FTP_TLS'): #use ftlib27 instead of ftplib
raise botslib.CommunicationError('FTPS is not supported by your python version, use >=2.7')
self.session = ftplib27.FTP_TLS() #use ftlib27 instead of ftplib
self.session.set_debuglevel(botsglobal.ini.getint('settings','ftpdebug',0)) #set debug level (0=no, 1=medium, 2=full debug)
self.session.set_pasv(not self.channeldict['ftpactive']) #active or passive ftp
self.session.connect(host=self.channeldict['host'],port=int(self.channeldict['port']))
#support key files (PEM, cert)?
try: # under /usersys/ftps_keys directory containing private (key) and public (pem) keys -- keynames are channel_name+.key or .pem
self.name_key = str(self.channeldict['idchannel'])+ '.key'
self.name_pem = str(self.channeldict['idchannel'])+ '.pem'
self.path_pem = os.path.join(self.channeldict['parameters'])+self.name_pem
self.path_key = os.path.join(self.channeldict['parameters'])+self.name_key
print self.path_pem
print self.path_key
self.session.keyfile = self.path_key
self.session.certfile = self.path_pem
except:
pass
self.session.auth()
self.session.login(user=self.channeldict['username'],passwd=self.channeldict['secret'],acct=self.channeldict['ftpaccount'])
self.session.prot_p()
self.dirpath = self.session.pwd()
if self.channeldict['path']:
self.dirpath = posixpath.normpath(posixpath.join(self.dirpath,self.channeldict['path']))
try:
self.session.cwd(self.dirpath) #set right path on ftp-server
except:
self.session.mkd(self.dirpath) #set right path on ftp-server; no nested directories
self.session.cwd(self.dirpath) #set right path on ftp-server
Kind regards,
JF