synapse/crypto/keyclient.py
def fetch_server_key(server_name, ssl_context_factory, path=KEY_API_V1):
    """Fetch the keys for a remote server."""

    factory = SynapseKeyClientFactory()
    factory.path = path
    factory.host = server_name
    endpoint = matrix_federation_endpoint(
        reactor, server_name, ssl_context_factory, timeout=30
    )

    for i in range(5):
        try:
            with logcontext.PreserveLoggingContext():
                protocol = yield endpoint.connect(factory)
                server_response, server_certificate = yield protocol.remote_key
                defer.returnValue((server_response, server_certificate))
        except SynapseKeyClientError as e:
            logger.exception("Error getting key for %r" % (server_name,))
            if e.status.startswith("4"):
                # Don't retry for 4xx responses.
                raise IOError("Cannot get key for %r" % server_name)
        except Exception as e:
            logger.exception(e)
    raise IOError("Cannot get key for %r" % server_name)
Fetch the keys for a remote server.
Fetch the keys for a remote server.
Fetch the keys for a remote server .
def fetch_server_key(server_name, ssl_context_factory, path=KEY_API_V1):
    factory = SynapseKeyClientFactory()
    factory.path = path
    factory.host = server_name
    endpoint = matrix_federation_endpoint(
        reactor, server_name, ssl_context_factory, timeout=30
    )
    for i in range(5):
        try:
            with logcontext.PreserveLoggingContext():
                protocol = yield endpoint.connect(factory)
                server_response, server_certificate = yield protocol.remote_key
                defer.returnValue((server_response, server_certificate))
        except SynapseKeyClientError as e:
            logger.exception("Error getting key for %r" % (server_name,))
            if e.status.startswith("4"):
                raise IOError("Cannot get key for %r" % server_name)
        except Exception as e:
            logger.exception(e)
    raise IOError("Cannot get key for %r" % server_name)
def fetch_server_key ( server_name , ssl_context_factory , path = KEY_API_V1 ) : factory = SynapseKeyClientFactory ( ) factory . path = path factory . host = server_name endpoint = matrix_federation_endpoint ( reactor , server_name , ssl_context_factory , timeout = 30 ) for i in range ( 5 ) : try : with logcontext . PreserveLoggingContext ( ) : protocol = yield endpoint . connect ( factory ) server_response , server_certificate = yield protocol . remote_key defer . returnValue ( ( server_response , server_certificate ) ) except SynapseKeyClientError as e : logger . exception ( "Error getting key for %r" % ( server_name , ) ) if e . status . startswith ( "4" ) : raise IOError ( "Cannot get key for %r" % server_name ) except Exception as e : logger . exception ( e ) raise IOError ( "Cannot get key for %r" % server_name )
Fetch the keys for a remote server.
Fetch the keys for a remote server .
"""Fetch the keys for a remote server.""" # Don't retry for 4xx responses.
server_name
ssl_context_factory
path