diff options
author | Erik Johnston <erik@matrix.org> | 2019-06-10 14:31:05 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2019-06-10 15:37:10 +0100 |
commit | 43badd2cd4315c3f3ed45b0092c4479a43a3eb52 (patch) | |
tree | fb90e173c2da212ef16b763b867337f7cb421558 /synapse | |
parent | 1.0.0rc1 (diff) | |
download | synapse-43badd2cd4315c3f3ed45b0092c4479a43a3eb52.tar.xz |
Fix key verification when key stored with null valid_until_ms
Some keys are stored in the synapse database with a null valid_until_ms which caused an exception to be thrown when using that key. We fix this by treating nulls as zeroes, i.e. they keys will match verification requests with a minimum_valid_until_ms of zero (i.e. don't validate ts) but will not match requests with a non-zero minimum_valid_until_ms. Fixes #5391.
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/storage/keys.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/synapse/storage/keys.py b/synapse/storage/keys.py index 5300720dbb..e3655ad8d7 100644 --- a/synapse/storage/keys.py +++ b/synapse/storage/keys.py @@ -80,6 +80,14 @@ class KeyStore(SQLBaseStore): for row in txn: server_name, key_id, key_bytes, ts_valid_until_ms = row + + if ts_valid_until_ms is None: + # Old keys may be stored with a ts_valid_until_ms of null, + # in which case we treat this as if it was set to `0`, i.e. + # it won't match key requests that define a minimum + # `ts_valid_until_ms`. + ts_valid_until_ms = 0 + res = FetchKeyResult( verify_key=decode_verify_key_bytes(key_id, bytes(key_bytes)), valid_until_ts=ts_valid_until_ms, |