Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Add some logging to 3pid invite sig verification (#5015)
Browse files Browse the repository at this point in the history
  • Loading branch information
anoadragon453 committed Feb 10, 2020
2 parents 2649c99 + f2d2ae0 commit 104d23b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog.d/5015.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add logging to 3pid invite signature verification.
46 changes: 38 additions & 8 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2763,25 +2763,55 @@ def _check_signature(self, event, context):
if not invite_event:
raise AuthError(403, "Could not find invite")

logger.debug("Checking auth on event %r", event.content)

last_exception = None
# for each public key in the 3pid invite event
for public_key_object in self.hs.get_auth().get_public_keys(invite_event):
try:
# for each sig on the third_party_invite block of the actual invite
for server, signature_block in signed["signatures"].items():
for key_name, encoded_signature in signature_block.items():
if not key_name.startswith("ed25519:"):
continue

public_key = public_key_object["public_key"]
verify_key = decode_verify_key_bytes(
key_name,
decode_base64(public_key)
logger.debug(
"Attempting to verify sig with key %s from %r "
"against pubkey %r",
key_name, server, public_key_object,
)
verify_signed_json(signed, server, verify_key)
if "key_validity_url" in public_key_object:
yield self._check_key_revocation(
public_key,

try:
public_key = public_key_object["public_key"]
verify_key = decode_verify_key_bytes(
key_name,
decode_base64(public_key)
)
verify_signed_json(signed, server, verify_key)
logger.debug(
"Successfully verified sig with key %s from %r "
"against pubkey %r",
key_name, server, public_key_object,
)
except Exception:
logger.info(
"Failed to verify sig with key %s from %r "
"against pubkey %r",
key_name, server, public_key_object,
)
raise
try:
if "key_validity_url" in public_key_object:
yield self._check_key_revocation(
public_key,
public_key_object["key_validity_url"]
)
except Exception:
logger.info(
"Failed to query key_validity_url %s",
public_key_object["key_validity_url"]
)
raise
return
except Exception as e:
last_exception = e
Expand Down

0 comments on commit 104d23b

Please sign in to comment.