Serving XML-RPC over HTTPS with Python

We've been talking about how to manage pygr resources remotely via the existing XML-RPC interface, and for that HTTPS is a requirement. I offered to track down the code necessary for running an XML-RPC server over HTTPS. Here's what I found:

It turns out that while the Python stdlib supports HTTPS client
connections (connecting to https:// URLs), it does not directly support
HTTPS serving.  To do that, you need to use pyOpenSSL.  However, once
that's installed it's a breeze: it's as simple as this,

  server = SecureXMLRPCServer(server_address, KEYFILE, CERTFILE)

You can download the SecureXMLRPCServer code and an example here:

To run it just install pyOpenSSL ('python-openssl' under Debian),
and then execute 'python' in one shell and 'python' in another.

Thanks to Laszlo Nagy for his Python Cookbook recipe which only needed a bit of fixing (for Python 2.5) and refactoring (for reusability).

The example .tar.gz above contains a private key and certification so that the code Just Works.


p.s. Ping me at if the .tar.gz file isn't accessible and I'll repost it.

Comments !

(Please check out the comments policy before commenting.)