diff options
| author | Robin Norwood <rnorwood@redhat.com> | 2007-09-25 10:38:51 -0400 |
|---|---|---|
| committer | Robin Norwood <rnorwood@redhat.com> | 2007-09-25 10:38:51 -0400 |
| commit | 6bf3d8bee599802c95832cbdae904ffce1053938 (patch) | |
| tree | 6711d28ed442ffbe5fddfdc6ccd1678ec05aa74c /client | |
| parent | 5024f7f62ff32345660fae783ac7a97d506fe1da (diff) | |
| parent | fca2c8e36dfec0ced3957ba8f6e62bf62a99c84b (diff) | |
Merge branch 'master' of git+ssh://git.fedoraproject.org/git/hosted/func
Conflicts:
func.spec
setup.py
Diffstat (limited to 'client')
| -rw-r--r-- | client/sslclient.py | 44 |
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 |
