summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorSeth Vidal <skvidal@fedoraproject.org>2007-09-25 10:27:06 -0400
committerSeth Vidal <skvidal@fedoraproject.org>2007-09-25 10:27:06 -0400
commitfc335d72bd444bc899b07042b7c11c814259f188 (patch)
tree3ba23a23ae5c1698659a3bcae5c511739035d3b2 /client
parent7d543b6cf1d721c2e9f7ed88a230172870a9f558 (diff)
- all the class bits to make the authssl xmlrpc server work - most of it copied and modified from plague
- modifications to setup.py to behave with func dir for python sitelib
Diffstat (limited to 'client')
-rw-r--r--client/sslclient.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/client/sslclient.py b/client/sslclient.py
new file mode 100644
index 0000000..5575deb
--- /dev/null
+++ b/client/sslclient.py
@@ -0,0 +1,44 @@
+#!/usr/bin/python
+
+import os
+import sys
+import xmlrpclib
+import urllib
+
+import SSLCommon
+
+
+class SSL_Transport(xmlrpclib.Transport):
+
+ user_agent = "pyOpenSSL_XMLRPC/%s - %s" % ('0.1', xmlrpclib.Transport.user_agent)
+
+ def __init__(self, ssl_context, timeout=None, use_datetime=0):
+ if sys.version_info[:3] >= (2, 5, 0):
+ xmlrpclib.Transport.__init__(self, use_datetime)
+ self.ssl_ctx=ssl_context
+ self._timeout = timeout
+
+ def make_connection(self, host):
+ # Handle username and password.
+ try:
+ host, extra_headers, x509 = self.get_host_info(host)
+ except AttributeError:
+ # Yay for Python 2.2
+ pass
+ _host, _port = urllib.splitport(host)
+ return SSLCommon.HTTPS(_host, int(_port), ssl_context=self.ssl_ctx, timeout=self._timeout)
+
+
+class SSLXMLRPCServerProxy(xmlrpclib.ServerProxy):
+ def __init__(self, uri, pkey_file, cert_file, ca_cert_file, timeout=None):
+ self.ctx = SSLCommon.CreateSSLContext(pkey_file, cert_file, ca_cert_file)
+ xmlrpclib.ServerProxy.__init__(self, uri, SSL_Transport(ssl_context=self.ctx, timeout=timeout))
+
+
+
+if __name__ == "__main__":
+ s = SSLXMLRPCServerProxy('https://localhost:51234/', '/etc/pki/func/slave.pem', '/etc/pki/func/slave.crt', '/etc/pki/func/ca/funcmaster.crt')
+ f = s.ping(1, 2)
+ print f
+
+ \ No newline at end of file