def _reset_proxy(self): parsed = urlparse(self.url.lower()) self.transport = None # This scheme is used for debugging and looping back if parsed.scheme == "test": self.proxy = BasicAuthServerProxy( test_to_http(self.url), username=self.username, password=self.password, transport=TestClientTransport()) elif parsed.scheme == "https": from M2Crypto.m2xmlrpclib import SSL_Transport from M2Crypto.SSL import Context self.transport = SSL_Transport(Context(protocol='tlsv1')) self.proxy = BasicAuthServerProxy(self.url, username=self.username, password=self.password, transport=self.transport, #verbose=getattr(settings, "DEBUG", False)) verbose=False) self.set_verify_certs() else: self.proxy = BasicAuthServerProxy(self.url, username=self.username, password=self.password)
def _get_client(self, cert_fname, key_fname): try: u = self.url except AttributeError: raise self.URLNotDefined("URL not set.") if not u: raise self.URLNotDefined("URL not set.") parsed = urlparse(u.lower()) if parsed.scheme == "test": user_cert = GID(filename=cert_fname).save_to_string() transport = TestClientTransport(defaults={ "REMOTE_USER": user_cert, "SSL_CLIENT_CERT": user_cert}) proxy = xmlrpclib.ServerProxy( test_to_http(u), transport=transport, ) else: transport = certtransport.SafeTransportWithCert( keyfile=key_fname, certfile=cert_fname) proxy = xmlrpclib.ServerProxy(u, transport=transport) return proxy
def _get_client(self, cert_fname, key_fname): try: u = self.url except AttributeError: raise self.URLNotDefined("URL not set.") if not u: raise self.URLNotDefined("URL not set.") parsed = urlparse(u.lower()) if parsed.scheme == "test": user_cert = GID(filename=cert_fname).save_to_string() transport = TestClientTransport(defaults={ "REMOTE_USER": user_cert, "SSL_CLIENT_CERT": user_cert }) proxy = xmlrpclib.ServerProxy( test_to_http(u), transport=transport, ) else: transport = certtransport.SafeTransportWithCert( keyfile=key_fname, certfile=cert_fname) proxy = xmlrpclib.ServerProxy(u, transport=transport) return proxy