1 """Leverage curl to make XMLRPC requests that check the server's credentials."""
3 from subprocess import PIPE, Popen
9 class CertificateCheckingSafeTransport(xmlrpclib.Transport):
10 def request(self, host, handler, request_body, verbose=0):
11 self.verbose = verbose
12 p = Popen((CURL, '--cacert', '/usr/boot/cacert.pem', '--data', '@-', 'https://%s%s' % (host, handler)), stdin=PIPE, stdout=PIPE, stderr=PIPE)
13 p.stdin.write(request_body)
15 contents = p.stdout.read()
17 error = p.stderr.read()
20 if rc != 0: raise xmlrpclib.ProtocolError(host + handler, rc, error, '')
21 return xmlrpclib.loads(contents)[0]
23 class ServerProxy(xmlrpclib.ServerProxy):
24 def __init__(self, handler, *args, **kw_args): xmlrpclib.ServerProxy.__init__(self, handler, CertificateCheckingSafeTransport())