def __init__(self, uuid, token, cert_file): self._uuid = uuid self._token = None self._creds = None self.set_token(token) # pin this agent with the platform TLS certificate factory = get_compatible_ssl_context_factory(cert_file) Agent.__init__(self, reactor, contextFactory=factory)
def __init__(self, cert_file=None, pool=_pool): """ Init the HTTP client :param cert_file: The path to the certificate file, if None given the system's CAs will be used. :type cert_file: str :param pool: An optional dedicated connection pool to override the default shared one. :type pool: HTTPConnectionPool """ policy = get_compatible_ssl_context_factory(cert_file) self._agent = Agent(reactor, policy, pool=pool) self._semaphore = defer.DeferredSemaphore(pool.maxPersistentPerHost)
def __init__(self, cert_file=None, pool=_pool): """ Init the HTTP client :param cert_file: The path to the certificate file, if None given the system's CAs will be used. :type cert_file: str :param pool: An optional dedicated connection pool to override the default shared one. :type pool: HTTPConnectionPool """ policy = get_compatible_ssl_context_factory(cert_file) self._agent = Agent( reactor, policy, pool=pool) self._semaphore = defer.DeferredSemaphore(pool.maxPersistentPerHost)
def __init__(self, url, source_replica_uid, creds, crypto, cert_file): """ Initialize the sync target. :param url: The server sync url. :type url: str :param source_replica_uid: The source replica uid which we use when deferring decryption. :type source_replica_uid: str :param creds: A dictionary containing the uuid and token. :type creds: creds :param crypto: An instance of SoledadCrypto so we can encrypt/decrypt document contents when syncing. :type crypto: soledad._crypto.SoledadCrypto :param cert_file: Path to the certificate of the ca used to validate the SSL certificate used by the remote soledad server. :type cert_file: str """ if url.endswith("/"): url = url[:-1] self._url = str(url) + "/sync-from/" + str(source_replica_uid) self.source_replica_uid = source_replica_uid self._auth_header = None self._uuid = None self.set_creds(creds) self._crypto = crypto # TODO: DEPRECATED CRYPTO self._deprecated_crypto = old_crypto.SoledadCrypto(crypto.secret) self._insert_doc_cb = None # Twisted default Agent with our own ssl context factory factory = get_compatible_ssl_context_factory(cert_file) self._http = Agent(reactor, factory) if DO_STATS: self.sync_exchange_phase = [0]
def __init__(self, cert_file=None, timeout=DEFAULT_HTTP_TIMEOUT, pool=None): """ Init the HTTP client :param cert_file: The path to the certificate file, if None given the system's CAs will be used. :type cert_file: str :param timeout: The amount of time that this Agent will wait for the peer to accept a connection and for each request to be finished. If a pool is passed, then this argument is ignored. :type timeout: float """ self._timeout = timeout self._pool = pool if pool is not None else self._pool self._agent = Agent( reactor, get_compatible_ssl_context_factory(cert_file), pool=self._pool, connectTimeout=self._timeout) self._semaphore = defer.DeferredSemaphore( self._pool.maxPersistentPerHost)