python xmlrpc client with ssl client certificates and standard modules
Martin v. Loewis
martin at v.loewis.de
Mon Jan 4 17:12:43 EST 2010
> I can do xmlrpc over ssl WITHOUT certificates with following code:
>
> import xmlrpclib
> server_url = 'https://myserver'
> server = xmlrpclib.Server(server_url);
>
>
> and I can perform a https get request WITH certificates with below snippet:
>
> import httplib
> conn = httplib.HTTPSConnection(
> HOSTNAME,
> key_file = KEYFILE,
> cert_file = CERTFILE
> )
> conn.putrequest('GET', '/')
> conn.endheaders()
> response = conn.getresponse()
> print response.read()
>
>
> I'm just lost of how to 'combine' both.
In this case, read through the source of xmlrpclib:
a) SafeTransport receives x509 parameters from get_host_info
b) get_host_info supports a case where host is a tuple host, x509
So, without testing:
server = xmlrpclib.Server((server_url, {'key_file': KEYFILE,
'cert_file': CERTFILE}))
Please do read the code before trying this out.
HTH,
Martin
More information about the Python-list
mailing list