-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
StoreKeyFetcher seems to do nothing if not using a trusted key server #15171
Description
Suppose we try to fetch keys from some homeserver we've never heard of.
We'll first try to use StoreKeyFetcher, which calls
synapse/synapse/crypto/keyring.py
Line 513 in 9bb2eac
| res = await self.store.get_server_verify_keys(key_ids_to_fetch) |
server_signature_keys: synapse/synapse/storage/databases/main/keys.py
Lines 65 to 68 in b76f1a4
| sql = ( | |
| "SELECT server_name, key_id, verify_key, ts_valid_until_ms " | |
| "FROM server_signature_keys WHERE 1=0" | |
| ) + " OR (server_name=? AND key_id=?)" * len(batch) |
That will return no keys. So next we'll try the PerspectivesKeyFetcher, but that will do nothing because we have no trusted key server configured.
So next we try the ServerKeyFetcher. That will fetch keys via
synapse/synapse/crypto/keyring.py
Line 844 in 9bb2eac
| keys = await self.get_server_verify_keys_v2_direct(server_name) |
and
synapse/synapse/crypto/keyring.py
Lines 901 to 905 in 9bb2eac
| return await self.process_v2_response( | |
| from_server=server_name, | |
| response_json=response, | |
| time_added_ms=time_now_ms, | |
| ) |
before caling
synapse/synapse/crypto/keyring.py
Line 605 in 9bb2eac
| self.store.store_server_keys_json, |
which writes to server_keys_json.
If we try to re-fetch keys for that server, we'll try the StoreKeyFetcher. But as we saw above, that reads from a different table (server_signature_keys). So we'll end up repeating the same steps and making another federation request via ServerKeyFetcher.