This commit is contained in:
Neil Alexander 2021-07-29 12:50:37 +01:00
parent 2fa479edca
commit 5654b08819
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -124,15 +124,21 @@ func (a *KeyInternalAPI) PerformUploadDeviceKeys(ctx context.Context, req *api.P
// NOT the master key then we also need to include the master key ID here
// as we won't accept a self-signing key or a user-signing key without it.
checkKeyIDs := make([]gomatrixserverlib.KeyID, 0, len(key.Signatures)+1)
if purpose != gomatrixserverlib.CrossSigningKeyPurposeMaster {
for keyID := range key.Signatures[req.UserID] {
checkKeyIDs = append(checkKeyIDs, keyID)
}
if purpose != gomatrixserverlib.CrossSigningKeyPurposeMaster {
if _, ok := key.Signatures[req.UserID][masterKeyID]; !ok {
checkKeyIDs = append(checkKeyIDs, masterKeyID)
}
}
// If there are no key IDs to check then there's no point marshalling
// the JSON.
if len(checkKeyIDs) == 0 && purpose == gomatrixserverlib.CrossSigningKeyPurposeMaster {
continue
}
// Marshal the specific key back into JSON so that we can verify the
// signature of it.
keyJSON, err := json.Marshal(key)