1 """Leverage curl to make XMLRPC requests that check the server's credentials."""
7 class CertificateCheckingSafeTransport(xmlrpclib.Transport):
8 def __init__(self, cacert, timeout):
10 self.timeout = timeout
12 def request(self, host, handler, request_body, verbose=0):
13 self.verbose = verbose
14 url='https://%s%s' % (host, handler)
16 contents = curlwrapper.retrieve(url,
18 postdata = request_body,
19 timeout = self.timeout)
20 return xmlrpclib.loads(contents)[0]
21 except curlwrapper.CurlException, e:
22 # when this triggers, the error sometimes doesn't get printed
23 print 'CertificateCheckingSafeTransport.request: Catching curlwrapper.CurlException with error <%s>'%str(e)
24 raise xmlrpclib.ProtocolError(url, -1, str(e), request_body)
26 class ServerProxy(xmlrpclib.ServerProxy):
27 def __init__(self, uri, cacert, timeout = 300, **kwds):
28 xmlrpclib.ServerProxy.__init__(self, uri,
29 CertificateCheckingSafeTransport(cacert, timeout),