mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-26 12:59:22 -05:00
Merge pull request #5300 from matrix-org/rav/server_keys/06-fix-serverkeys-handling
Remove some pointless exception handling
This commit is contained in:
commit
fe79b5e521
1
changelog.d/5300.bugfix
Normal file
1
changelog.d/5300.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fix noisy 'no key for server' logs.
|
@ -64,13 +64,19 @@ class VerifyKeyRequest(object):
|
|||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
server_name(str): The name of the server to verify against.
|
server_name(str): The name of the server to verify against.
|
||||||
|
|
||||||
key_ids(set[str]): The set of key_ids to that could be used to verify the
|
key_ids(set[str]): The set of key_ids to that could be used to verify the
|
||||||
JSON object
|
JSON object
|
||||||
|
|
||||||
json_object(dict): The JSON object to verify.
|
json_object(dict): The JSON object to verify.
|
||||||
|
|
||||||
deferred(Deferred[str, str, nacl.signing.VerifyKey]):
|
deferred(Deferred[str, str, nacl.signing.VerifyKey]):
|
||||||
A deferred (server_name, key_id, verify_key) tuple that resolves when
|
A deferred (server_name, key_id, verify_key) tuple that resolves when
|
||||||
a verify key has been fetched. The deferreds' callbacks are run with no
|
a verify key has been fetched. The deferreds' callbacks are run with no
|
||||||
logcontext.
|
logcontext.
|
||||||
|
|
||||||
|
If we are unable to find a key which satisfies the request, the deferred
|
||||||
|
errbacks with an M_UNAUTHORIZED SynapseError.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
server_name = attr.ib()
|
server_name = attr.ib()
|
||||||
@ -771,31 +777,8 @@ def _handle_key_deferred(verify_request):
|
|||||||
SynapseError if there was a problem performing the verification
|
SynapseError if there was a problem performing the verification
|
||||||
"""
|
"""
|
||||||
server_name = verify_request.server_name
|
server_name = verify_request.server_name
|
||||||
try:
|
|
||||||
with PreserveLoggingContext():
|
with PreserveLoggingContext():
|
||||||
_, key_id, verify_key = yield verify_request.deferred
|
_, key_id, verify_key = yield verify_request.deferred
|
||||||
except KeyLookupError as e:
|
|
||||||
logger.warn(
|
|
||||||
"Failed to download keys for %s: %s %s",
|
|
||||||
server_name,
|
|
||||||
type(e).__name__,
|
|
||||||
str(e),
|
|
||||||
)
|
|
||||||
raise SynapseError(
|
|
||||||
502, "Error downloading keys for %s" % (server_name,), Codes.UNAUTHORIZED
|
|
||||||
)
|
|
||||||
except Exception as e:
|
|
||||||
logger.exception(
|
|
||||||
"Got Exception when downloading keys for %s: %s %s",
|
|
||||||
server_name,
|
|
||||||
type(e).__name__,
|
|
||||||
str(e),
|
|
||||||
)
|
|
||||||
raise SynapseError(
|
|
||||||
401,
|
|
||||||
"No key for %s with id %s" % (server_name, verify_request.key_ids),
|
|
||||||
Codes.UNAUTHORIZED,
|
|
||||||
)
|
|
||||||
|
|
||||||
json_object = verify_request.json_object
|
json_object = verify_request.json_object
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user