From b7059ddd184d64f483d31412113021121967f298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Wed, 14 Aug 2024 16:02:09 +0200 Subject: [PATCH] federation-api: Allow old_verify_keys to be missing when deserializing ServerSigningKeys --- crates/ruma-federation-api/CHANGELOG.md | 5 +++++ crates/ruma-federation-api/src/discovery.rs | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/ruma-federation-api/CHANGELOG.md b/crates/ruma-federation-api/CHANGELOG.md index edd0899d..88a176fa 100644 --- a/crates/ruma-federation-api/CHANGELOG.md +++ b/crates/ruma-federation-api/CHANGELOG.md @@ -1,5 +1,10 @@ # [unreleased] +Bug fixes: + +- `ServerSigningKeys` can be deserialized when `old_verify_keys` is missing, due to a + clarification in the spec. + Improvements: - Add support for authenticated media endpoints, according to MSC3916 / Matrix 1.11 diff --git a/crates/ruma-federation-api/src/discovery.rs b/crates/ruma-federation-api/src/discovery.rs index 9ebb2368..b97bd609 100644 --- a/crates/ruma-federation-api/src/discovery.rs +++ b/crates/ruma-federation-api/src/discovery.rs @@ -48,7 +48,6 @@ impl OldVerifyKey { } } -// Spec is wrong, all fields are required (see https://github.com/matrix-org/matrix-spec/issues/613) /// Queried server key, signed by the notary server. #[derive(Clone, Debug, Deserialize, Serialize)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] @@ -60,6 +59,9 @@ pub struct ServerSigningKeys { pub verify_keys: BTreeMap, /// Public keys that the homeserver used to use and when it stopped using them. + // This field is optional, but all fields were assumed to be required before clarification + // in https://github.com/matrix-org/matrix-spec/pull/1930, so we still send it. + #[serde(default)] pub old_verify_keys: BTreeMap, /// Digital signatures of this object signed using the verify_keys.