remove extraneous exception logging

This commit is contained in:
Richard van der Hoff 2019-04-25 21:08:12 +01:00
parent 7ca638c761
commit fd8fb32bdd
2 changed files with 34 additions and 18 deletions

View File

@ -114,37 +114,53 @@ class Keyring(object):
server_name. The deferreds run their callbacks in the sentinel
logcontext.
"""
# a list of VerifyKeyRequests
verify_requests = []
handle = preserve_fn(_handle_key_deferred)
for server_name, json_object in server_and_json:
def process(server_name, json_object):
"""Process an entry in the request list
Given a (server_name, json_object) pair from the request list,
adds a key request to verify_requests, and returns a deferred which will
complete or fail (in the sentinel context) when verification completes.
"""
key_ids = signature_ids(json_object, server_name)
if not key_ids:
deferred = defer.fail(SynapseError(
return defer.fail(
SynapseError(
400,
"Not signed by %s" % (server_name, ),
"Not signed by %s" % (server_name,),
Codes.UNAUTHORIZED,
))
else:
deferred = defer.Deferred()
)
)
logger.debug("Verifying for %s with key_ids %s",
server_name, key_ids)
# add the key request to the queue, but don't start it off yet.
verify_request = VerifyKeyRequest(
server_name, key_ids, json_object, deferred
server_name, key_ids, json_object, defer.Deferred(),
)
verify_requests.append(verify_request)
# now run _handle_key_deferred, which will wait for the key request
# to complete and then do the verification.
#
# We want _handle_key_request to log to the right context, so we
# wrap it with preserve_fn (aka run_in_background)
return handle(verify_request)
results = [
process(server_name, json_object)
for server_name, json_object in server_and_json
]
if verify_requests:
run_in_background(self._start_key_lookups, verify_requests)
# Pass those keys to handle_key_deferred so that the json object
# signatures can be verified
handle = preserve_fn(_handle_key_deferred)
return [
handle(rq) for rq in verify_requests
]
return results
@defer.inlineCallbacks
def _start_key_lookups(self, verify_requests):

View File

@ -274,7 +274,7 @@ def _check_sigs_on_pdus(keyring, room_version, pdus):
"event id %s: unable to verify signature for sender %s: %s",
pdu_to_check.pdu.event_id,
pdu_to_check.sender_domain,
e,
e.getErrorMessage(),
)
return e
@ -305,7 +305,7 @@ def _check_sigs_on_pdus(keyring, room_version, pdus):
logger.warning(
"event id %s: unable to verify signature for event id domain: %s",
pdu_to_check.pdu.event_id,
e,
e.getErrorMessage(),
)
return e