From ac25065a54149117761e7a1b471a9b742f920ebc Mon Sep 17 00:00:00 2001 From: S7evinK <2353100+S7evinK@users.noreply.github.com> Date: Wed, 9 Feb 2022 13:11:43 +0100 Subject: [PATCH] Fix sytest `uploading signed devices gets propagated over federation` (#2162) * Remove unneeded logging * Add MasterKey & SelfSigningKey to update Avoid panic if signatures are not present * Add passing test * Revert "Add MasterKey & SelfSigningKey to update" This reverts commit 2c81b34884be8b5b875a33420c0f985b578d3fb8. * Send MasterKey & SelfSigningKey with update * Debugging * Remove delete() so we also query signingkeys --- federationapi/consumers/roomserver.go | 6 +----- keyserver/internal/cross_signing.go | 6 +++++- keyserver/internal/internal.go | 7 ++++++- sytest-whitelist | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/federationapi/consumers/roomserver.go b/federationapi/consumers/roomserver.go index 60066bb2..ac29f930 100644 --- a/federationapi/consumers/roomserver.go +++ b/federationapi/consumers/roomserver.go @@ -18,6 +18,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/matrix-org/dendrite/federationapi/queue" "github.com/matrix-org/dendrite/federationapi/storage" "github.com/matrix-org/dendrite/federationapi/types" @@ -113,11 +114,6 @@ func (s *OutputRoomEventConsumer) onMessage(ctx context.Context, msg *nats.Msg) } } - case api.OutputTypeNewInviteEvent: - log.WithField("type", output.Type).Debug( - "received new invite, send device keys", - ) - case api.OutputTypeNewInboundPeek: if err := s.processInboundPeek(*output.NewInboundPeek); err != nil { log.WithFields(log.Fields{ diff --git a/keyserver/internal/cross_signing.go b/keyserver/internal/cross_signing.go index 527990cf..bfb2037f 100644 --- a/keyserver/internal/cross_signing.go +++ b/keyserver/internal/cross_signing.go @@ -308,8 +308,12 @@ func (a *KeyInternalAPI) PerformUploadDeviceSignatures(ctx context.Context, req // Finally, generate a notification that we updated the signatures. for userID := range req.Signatures { + masterKey := queryRes.MasterKeys[userID] + selfSigningKey := queryRes.SelfSigningKeys[userID] update := eduserverAPI.CrossSigningKeyUpdate{ - UserID: userID, + UserID: userID, + MasterKey: &masterKey, + SelfSigningKey: &selfSigningKey, } if err := a.Producer.ProduceSigningKeyUpdate(update); err != nil { res.Error = &api.KeyError{ diff --git a/keyserver/internal/internal.go b/keyserver/internal/internal.go index 25924921..2536c1f7 100644 --- a/keyserver/internal/internal.go +++ b/keyserver/internal/internal.go @@ -326,8 +326,14 @@ func (a *KeyInternalAPI) QueryKeys(ctx context.Context, req *api.QueryKeysReques if err = json.Unmarshal(key, &deviceKey); err != nil { continue } + if deviceKey.Signatures == nil { + deviceKey.Signatures = map[string]map[gomatrixserverlib.KeyID]gomatrixserverlib.Base64Bytes{} + } for sourceUserID, forSourceUser := range sigMap { for sourceKeyID, sourceSig := range forSourceUser { + if _, ok := deviceKey.Signatures[sourceUserID]; !ok { + deviceKey.Signatures[sourceUserID] = map[gomatrixserverlib.KeyID]gomatrixserverlib.Base64Bytes{} + } deviceKey.Signatures[sourceUserID][sourceKeyID] = sourceSig } } @@ -447,7 +453,6 @@ func (a *KeyInternalAPI) queryRemoteKeysOnServer( for userID, deviceIDs := range devKeys { if len(deviceIDs) == 0 { userIDsForAllDevices[userID] = struct{}{} - delete(devKeys, userID) } } // for cross-signing keys, it's probably easier just to hit /keys/query if we aren't already doing diff --git a/sytest-whitelist b/sytest-whitelist index c6ce1daa..04b1bbf3 100644 --- a/sytest-whitelist +++ b/sytest-whitelist @@ -591,3 +591,4 @@ Can receive redactions from regular users over federation in room version 9 Forward extremities remain so even after the next events are populated as outliers If a device list update goes missing, the server resyncs on the next one uploading self-signing key notifies over federation +uploading signed devices gets propagated over federation