Channel using ftps

81 views
Skip to first unread message

Jean-François

unread,
Feb 2, 2012, 11:20:55 AM2/2/12
to Bots Open Source EDI Translator
Hi all,

I do see FTPS as a means of connection. Did anyone already use it? I
see it requires Python >= 2.7, how about compatibility with Bots 2.0.X
or 2.1?
Where do we indicate/specify private and public keys?
This is my next challenge with Bots :-)) Any help welcome.

Kind regards

JF

hjeb...@gmail.com

unread,
Feb 3, 2012, 10:30:05 AM2/3/12
to bots...@googlegroups.com
hi Jean-Francois,

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

Jean-François

unread,
Feb 22, 2012, 3:24:36 AM2/22/12
to Bots Open Source EDI Translator
Hi Henk-Jan,

Thanks for your answer. We're going to use implicit FTPS (port 990),
but we'll need to handle the private key.
Do you suggest to do that in a CommunicationScript? Do we have to
check communication.py?
Any clue appreciated :-)

Kind regards,

JF

On 3 fév, 16:30, "hjebb...@gmail.com" <hjebb...@gmail.com> wrote:
> hi Jean-Francois,
>
> I useFTPS
> there are several variant ofFTPS, 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
>
> On 02/02/2012 05:20 PM, Jean-François wrote:
>
>
>
>
>
>
>
> > Hi all,
>
> > I do seeFTPSas a means of connection. Did anyone already use it? I

hjeb...@gmail.com

unread,
Mar 8, 2012, 7:10:13 AM3/8/12
to bots...@googlegroups.com
hi Jean-François,

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

Jean-François Van Snick

unread,
Mar 8, 2012, 7:34:23 AM3/8/12
to bots...@googlegroups.com
Hi Henk-Jan,

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

henk-jan ebbers

unread,
May 22, 2012, 7:13:28 AM5/22/12
to bots...@googlegroups.com
hi Jean-François,

just added code in communication/py that handles key files.
for now this is done a a user exit.

kind regards,
henk-jan

On 03/08/2012 01:34 PM, Jean-François Van Snick wrote:
> Hi Henk-Jan,
>
> 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) :-)

Jean-François Van Snick

unread,
May 23, 2012, 3:19:52 AM5/23/12
to bots...@googlegroups.com
Hi Henk-Jan,

Thanks for this. I guess this would be part of next BOTS release... I'll have a look.

Kind regards,

JF
Reply all
Reply to author
Forward
0 new messages