[Twisted-Python] jabber sasl and TLS

Nathaniel Haggard natester at gmail.com
Fri Jul 1 19:40:42 EDT 2005


Ok I patched the latest twisted with those patches from the bug, and
this is the code that I use to try to login.

from twisted.words.protocols import jabber
from twisted.xish import xmlstream
from twisted.words.protocols.jabber import client, jid
from twisted.internet import reactor, defer

class Connection:
    def __init__(self, who, myjid):
        self.jid = jid.JID(myjid)
        self.who = who

    def connect(self, passwd, port=5223):
        self.factory = client.jabberClientFactory(self.jid, passwd)
        
        self.factory.addBootstrap(xmlstream.STREAM_AUTHD_EVENT,self.onAuthSuccess)
        self.factory.addBootstrap(client.XMPPAuthenticator.AUTH_FAILED_EVENT,self.onAuthFailed)
        
        self.connector = reactor.connectTCP(self.jid.host, port, self.factory)
    
    def onAuthSuccess(self, stream):
        print "%s: Successful connection" % (self.who)
        self.stream = stream

    def onAuthFailed(self, stream):
        print "%s: Failed connection" % (self.who)
        self.factory.stopTrying()
        self.connector.disconnect()

c1 = Connection('1', 'test at domain.com/res1')
c1.connect('pass')

reactor.run()

jabberd 2.0s8 (on linux with openssl 0.9.7d) complains with this error:

C2S : Fri Jul  1 17:20:55 2005 [notice] [6] [10.1.2.111, port=49443]
error: SSL handshake error (error:140760FC:SSL
routines:SSL23_GET_CLIENT_HELLO:unknown protocol)
C2S : sx (sx.c:55) allocated new sx for 6
C2S : Fri Jul  1 17:21:47 2005 [notice] [7] [10.1.2.111, port=49444] connect

The server is setup to do TLS auth only on port 5223. 

Nate

On 7/1/05, Nathaniel Haggard <natester at gmail.com> wrote:
> Where is the code now and can I help you by using it?
> 
> Nate
> 
> On 7/1/05, Ralph Meijer <twisted at ralphm.ik.nu> wrote:
> > On Fri, Jul 01, 2005 at 09:37:46AM -0600, Nathaniel Haggard wrote:
> > > What is the status of the sasl TLS jabber authenticator?  There is
> > > this code from about a month ago:
> > > http://bfs.itlab.musc.edu/pubcvs/viewcvs.cgi/tofu/saslclient.py#rev1.6,
> > > but it does not include TLS.
> >
> > Yes, tofu has submitted this code, and I, the maintainer of the Jabber
> > pieces in Twisted, am looking at integrating this. However, to do this
> > right, there are some fundamental changes necessary in Xish and the
> > Jabber module. I'm working on this, and will update the bug with
> > progress.
> >
> > If you have any more questions, do ask in this list.
> >
> > --
> > Groetjes,
> >
> > ralphm
> >
>




More information about the Twisted-Python mailing list