M2Crypto / SimpleXMLRPCServer

Ben Beuchler insyte-clp at emt-p.org
Thu Jun 20 00:50:06 EDT 2002


I'm trying to set up an SSL SimpleXMLRPCServer instance.  I've
successfully used the xmlrpc_srv.py demo script from the M2 distro, but
would like access to the convenience of .register_function() and
.register_instance().

It looks to me like SSL.SSLServer and its various derivatives (Threading,
Forking) *should* be a drop-in replacement for SocketServer.TCPServer when
instantiating SimpleXMLRPCServer.  I attempted to derive a
SimpleSSLXMLRPCServer class like this (after setting up an appropriate
ssl_context):

class SimpleSSLXMLRPCServer(SSL.SSLServer, SimpleXMLRPCServer):
    def __init__(self, ssl_context, address, 
                 RequestHandler=SimpleXMLRPCRequestHandler, logRequests=1):
      SSL.SSLServer.__init__(self, address, RequestHandler, ssl_context)
      self.funcs{}                     # These three lines are copied from
      self.logRequests = logRequests   # SimpleXMLRPCServer's __init__, as 
      self.instance = None             # calling it would create non-ssl
                                       # sockets. 

My understanding is that the methods in SSL.SSLServer would override the
methods inherited by SimpleXMLRPCServer from SocketServer.TCPServer.

It appears that the SSL part, at least, works great.  I'm able to make a
connection using xmlrpclib.ServerProxy("https://blah") but the actual
remote method call hangs indefinitely.

Is my basic premise flawed?  Or just my implementation?

Here's the output on the server side:

>>> ctx = init_context('server.pem', 'ca.pem', SSL.verify_none)
>>> bob = SimpleSSLXMLRPCServer(ctx, ('216.243.168.40', 9090))
>>> def q(a,b):
...     return a + b
...
>>> bob.register_function(q)
>>> bob.serve_forever()
LOOP: SSL accept: before/accept initialization
LOOP: SSL accept: SSLv3 read client hello A
LOOP: SSL accept: SSLv3 write server hello A
LOOP: SSL accept: SSLv3 write certificate A
LOOP: SSL accept: SSLv3 write server done A
LOOP: SSL accept: SSLv3 flush data
LOOP: SSL accept: SSLv3 read client key exchange A
LOOP: SSL accept: SSLv3 read finished A
LOOP: SSL accept: SSLv3 write change cipher spec A
LOOP: SSL accept: SSLv3 write finished A
LOOP: SSL accept: SSLv3 flush data
INFO: SSL accept: SSL negotiation finished successfully
petra.bitstream.net - - [19/Jun/2002 22:27:55] "POST /RPC2 HTTP/1.0" 200 -

The client side is unremarkable.  I instantiate a ServerProxy and attempt
to make a remote call.  It hangs.  Very boring.

Any thoughts?

-Ben

-- 
Ben Beuchler                                           There is no spoon.
insyte at emt-p.org                                            -- The Matrix



More information about the Python-list mailing list