[pyOpenSSL] pyopenssl and xmlrpclib

Andrew Gaffney agaffney at gentoo.org
Sun Jun 18 21:09:58 CEST 2006


Dan Williams wrote:
> On Thu, 2006-06-15 at 10:14 -0500, Andrew Gaffney wrote:
>> I'm trying to integrate xmlrpclib and pyopenssl. I'm mostly there, but I'm 
>> running into a problem:
> 
> If you need some example code of doing SSL and all things XMLRPC, take a
> look at the files here:
> 
> http://cvs.fedora.redhat.com/viewcvs/extras-buildsys/common/?root=fedora
> 
> specifically SSLCommon.py and SSLConnection.py.  Furthermore,
> XMLRPCServerProxy.py, URLopener.py, FileTranser.py, FileDownloader.py,
> and FileUploader.py might be of of interest as well.
> 
> These implementations use nonblocking sockets by default, which have a
> few other complications, but you can safely turn that off by passing
> timeout values of None, I think.
> 
> We've been running variations on this code for almost a year now in the
> Fedora Extras build system, and it's been working pretty well.
> 
> Dan

The RH implementation is close to what I had come up with, so I at least know I 
was on the right track. That does get me a little farther, however, there's a 
still a problem somewhere. I've modified my code to be as close to the RH code 
and still have my own touches.

Currently, it looks like the request is sent, the headers are received back from 
the server, and then the connection closes (but in a weird way). The 'closed' 
var is getting set in the SSLConnection class, but stuff like select.select() 
and socket.revc() don't seem to notice...they return "Bad file descriptor". I 
added some code to SSLConnection's recv() to check self.closed and return None, 
which gets me past that error. At that point, I get an exception from the XML 
parsing code in xmlrpclib, apparently because no XML was ever sent back. The 
following is a transcript of the session with the client code:

POST /RPC2 HTTP/1.0
Host: localhost:9876
User-Agent: xmlrpclib.py/1.0.1 (by www.pythonware.com)
Content-Type: text/xml
Content-Length: 103

<?xml version='1.0'?>
<methodCall>
<methodName>say_hello</methodName>
<params>
</params>
</methodCall>


HTTP/1.0 200 OK
Server: BaseHTTP/0.3 Python/2.4.3
Date: Sun, 18 Jun 2006 18:16:09 GMT
Content-type: text/xml
Content-length: 131


and the socket is closed. This definitely seems to be a client-side problem. I 
used 'openssl s_client' to make sure of this:

POST /RPC2 HTTP/1.0
Host: localhost:9876
User-Agent: xmlrpclib.py/1.0.1 (by www.pythonware.com)
Content-Type: text/xml
Content-Length: 103

<?xml version='1.0'?>
<methodCall>
<methodName>say_hello</methodName>
<params>
</params>
</methodCall>
HTTP/1.0 200 OK
Server: BaseHTTP/0.3 Python/2.4.3
Date: Sun, 18 Jun 2006 18:28:16 GMT
Content-type: text/xml
Content-length: 131

<?xml version='1.0'?>
<methodResponse>
<params>
<param>
<value><string>hello</string></value>
</param>
</params>
</methodResponse>
closed


The current version of my code can be found at 
<http://dev.gentoo.org/~agaffney/misc/scirec/>. If it makes any difference, I'm 
using python-2.4.3, pyopenssl-0.6, and openssl-0.9.7j. Thanks for any help in 
getting this working.

-- 
Andrew Gaffney                            http://dev.gentoo.org/~agaffney/
Gentoo Linux Developer                                   Installer Project




More information about the pyopenssl-users mailing list