xmlrpc ssl (slightly embarrassing, long post)

Rune Hansen rune.hansen at sinsenveien83.com
Thu Jun 5 15:22:04 CEST 2003

Hi, I'm slightly embarrassed to ask these questions, mainly because I
fear that I've yet to full grasp the problem at hand. I'm trying to use 
in communication with a xmlrpc server. Both server and client should
preferably be build with python. I'm reasoning that I need a
socket.ssl() object.(BTW I've created a key and cert file with the
help of the openssl how-to found at
 >>> import socket
 >>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 >>> ssl = socket.ssl(s, 'key.pem','cert.pem')
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
socket.error: (32, 'Broken pipe')
Now, my ignorance begins to show. This is obviously not right. After
all, I want to use SimpleXMLRPCServer....so...I found some code on

Using this code I rewrote:
class TCPServer(BaseServer):
     address_family = socket.AF_INET
     socket_type = socket.SOCK_STREAM
     request_queue_size = 5
     allow_reuse_address = 0

     def __init__(self, server_address, RequestHandlerClass):
         """Constructor.  May be extended, do not override."""
         BaseServer.__init__(self, server_address, RequestHandlerClass)
         ctx = SSL.Context(SSL.SSLv23_METHOD)
         ctx.set_verify(SSL.VERIFY_PEER, verify_cb)
         ctx.use_privatekey_file ('key.pem')
         self.socket = 


, blatantly ignoring the "May be extended, do not override"
warning(!), and wrote a wrapper for SimpleXMLRPCServer(to make use of
the new TCPServer class). Creating and starting a server based on this
SimpleXMLRPCServer class goes witout a hitch. But when connecting to
the server I get this traceback on the client:
 >>> import xmlrpclib
 >>> s = xmlrpclib.Server('https://localhost:8000')
 >>> p = s.postnr('1411')
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "//usr/lib/python2.2/xmlrpclib.py", line 821, in __call__
     return self.__send(self.__name, args)
   File "//usr/lib/python2.2/xmlrpclib.py", line 975, in __request
   File "//usr/lib/python2.2/xmlrpclib.py", line 840, in request
     self.send_content(h, request_body)
   File "//usr/lib/python2.2/xmlrpclib.py", line 876, in send_content
   File "//usr/lib/python2.2/httplib.py", line 695, in endheaders
   File "//usr/lib/python2.2/httplib.py", line 581, in _send_output
   File "//usr/lib/python2.2/httplib.py", line 548, in send
   File "//usr/lib/python2.2/httplib.py", line 945, in connect
     ssl = socket.ssl(realsock, self.key_file, self.cert_file)
socket.sslerror: (8, 'EOF occurred in violation of protocol')

And this error message on the server:
exception happened during processing of request from ('', 49579)
Traceback (most recent call last):
   File "//usr/lib/python2.2/SocketServer.py", line 221, in handle_request
     self.process_request(request, client_address)
   File "//usr/lib/python2.2/SocketServer.py", line 240, in process_request
     self.finish_request(request, client_address)
   File "//usr/lib/python2.2/SocketServer.py", line 253, in finish_request
     self.RequestHandlerClass(request, client_address, self)
   File "//usr/lib/python2.2/SocketServer.py", line 513, in __init__
   File "//usr/lib/python2.2/SocketServer.py", line 553, in setup
     self.rfile = self.connection.makefile('rb', self.rbufsize)
NotImplementedError: Cannot make file object of SSL.Connection

Did I mention that I really don't know what I'm doing? Uhm..yes, I
believe I did. Anyways, I would be very happy if someone could
enlighten me...



More information about the Python-list mailing list