[Twisted-Python] VC++ client and a Twisted OpenSSL Server

gary clark burslem2001 at yahoo.com
Wed Sep 23 11:04:44 EDT 2009


Firstly I'm new to twisted hence patience and a deep breath my be necessary.

I wrote a simple VC++ client that communicates to a VC++ server using OpenSSL. It loads .pem file and communicates great.

However I want the client to talk to a twisted server provided from TwistedMatrix:

# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
# See LICENSE for details.

from OpenSSL import SSL
from twisted.internet.protocol import Factory
from twisted.internet import ssl, reactor
from twisted.python import log

class ServerContextFactory:

    def getContext(self):
        """Create an SSL context.
        This is a sample implementation that loads a certificate from a file 
        called 'server.pem'."""
        ctx = SSL.Context(SSL.SSLv23_METHOD)
        return ctx

if __name__ == '__main__':
    import echoserv, sys
    factory = Factory()
    factory.protocol = echoserv.Echo
    port =int(sys.argv[1])
    reactor.listenSSL(port, factory, ServerContextFactory())

When attempting to connect the client, it failed on BIO_do_connect.

Has anybody attempted to do this? If so could they shed some light into the direction of getting the BIO to connect.


More information about the Twisted-Python mailing list