diff options
author | Seth Vidal <skvidal@fedoraproject.org> | 2007-09-25 11:02:26 -0400 |
---|---|---|
committer | Seth Vidal <skvidal@fedoraproject.org> | 2007-09-25 11:02:26 -0400 |
commit | 47100aa2f165b47175af1e1aef736c5769a83169 (patch) | |
tree | f62266e0490053acfa50989cbd91fc5b3f05cabf /overlord | |
parent | 4ce41f6eb4bdef401dd767d48ea98a0883090972 (diff) | |
download | third_party-func-47100aa2f165b47175af1e1aef736c5769a83169.tar.gz third_party-func-47100aa2f165b47175af1e1aef736c5769a83169.tar.xz third_party-func-47100aa2f165b47175af1e1aef736c5769a83169.zip |
move files for the new naming scheme
Diffstat (limited to 'overlord')
-rw-r--r-- | overlord/sslclient.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/overlord/sslclient.py b/overlord/sslclient.py new file mode 100644 index 0000000..9439c4a --- /dev/null +++ b/overlord/sslclient.py @@ -0,0 +1,44 @@ +#!/usr/bin/python + +import os +import sys +import xmlrpclib +import urllib + +from func 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 |