5 from func
import SSLCommon
8 class SSL_Transport(xmlrpclib
.Transport
):
10 user_agent
= "pyOpenSSL_XMLRPC/%s - %s" % ('0.1', xmlrpclib
.Transport
.user_agent
)
12 def __init__(self
, ssl_context
, timeout
=None, use_datetime
=0):
13 if sys
.version_info
[:3] >= (2, 5, 0):
14 xmlrpclib
.Transport
.__init
__(self
, use_datetime
)
15 self
.ssl_ctx
=ssl_context
16 self
._timeout
= timeout
18 def make_connection(self
, host
):
19 # Handle username and password.
21 host
, extra_headers
, x509
= self
.get_host_info(host
)
22 except AttributeError:
25 _host
, _port
= urllib
.splitport(host
)
26 return SSLCommon
.HTTPS(_host
, int(_port
), ssl_context
=self
.ssl_ctx
, timeout
=self
._timeout
)
29 class SSLXMLRPCServerProxy(xmlrpclib
.ServerProxy
):
30 def __init__(self
, uri
, pkey_file
, cert_file
, ca_cert_file
, timeout
=None):
31 self
.ctx
= SSLCommon
.CreateSSLContext(pkey_file
, cert_file
, ca_cert_file
)
32 xmlrpclib
.ServerProxy
.__init
__(self
, uri
, SSL_Transport(ssl_context
=self
.ctx
, timeout
=timeout
))
35 class FuncServer(SSLXMLRPCServerProxy
):
36 def __init__(self
, uri
, pem
=None, crt
=None, ca
=None):
41 SSLXMLRPCServerProxy
.__init
__(self
, uri
,
47 if __name__
== "__main__":
48 s
= SSLXMLRPCServerProxy('https://localhost:51234/', '/etc/pki/func/slave.pem', '/etc/pki/func/slave.cert', '/etc/pki/func/ca/funcmaster.crt')