How do I use TLS with asyncore?
Question: An asyncore-based XMPP client opens a normal TCP connection to an XMPP server.
The server indicates it requires an encrypted connection. The client is now
expected to start a TLS handshake so that subsequent requests can be
encrypted.

[tlslite](http://trevp.net/tlslite/readme.txt) integrates with asyncore, but
the sample code is for a server (?) and I don't understand what it's doing.

I'm on Python 2.5. How can I get the TLS magic working?

* * *

Here's what ended up working for me:

    
    
    from tlslite.api import *
    
    def handshakeTls(self):
        """
        Encrypt the socket using the tlslite module
        """
        self.logger.info("activating TLS encrpytion")
        self.socket = TLSConnection(self.socket)
        self.socket.handshakeClientCert()
    


Answer: Definitely check out twisted and wokkel. I've been building tons of xmpp bots
and components with it and it's a dream.

