mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-10 05:58:11 +00:00
`KeyStore.get_server_keys_json` orders the `server_keys_json` rows of a key by `ts_added_ms` and each row overwrites the previous one, so the last notary to answer wins even when its `ts_valid_until_ms` is lower than an earlier answer's. When that answer is stale, `StoreKeyFetcher` returns a key below `minimum_valid_until_ts` and event signature verification fails although a long enough key is stored. The query now orders by `ts_valid_until_ms, ts_added_ms`, so the longest-valid entry wins and the most recent one still wins a tie. `tests/crypto/test_keyring.py` stores two notary responses for one key, the longer-lived one first, and checks that the lookup and `verify_json_for_server` use it. Not covered: `get_server_keys_json_for_remote` and `get_all_server_keys_json_for_remote`, which still prefer the most recently added row. Fixes #20358 ### Pull Request Checklist * [x] Pull request is based on the develop branch * [x] Pull request includes a [changelog file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog). * [x] [Code style](https://element-hq.github.io/synapse/latest/code_style.html) is correct (ruff check, ruff format and mypy run on the changed files)