diff --git a/src/github.com/matrix-org/dendrite/common/threepid/checksignature.go b/src/github.com/matrix-org/dendrite/common/threepid/checksignature.go index 71afaf03a..18b5edb21 100644 --- a/src/github.com/matrix-org/dendrite/common/threepid/checksignature.go +++ b/src/github.com/matrix-org/dendrite/common/threepid/checksignature.go @@ -30,37 +30,18 @@ import ( // Returns nil if all the verifications succeeded. // Returns an error if something failed in the process. func CheckIDServerSignatures(idServer string, signatures map[string]map[string]string, marshalledBody []byte) error { - if len(idServer) > 0 { - // TODO: Check if the domain is part of a list of trusted ID servers - idServerSignatures, ok := signatures[idServer] - if !ok { - return errors.New("No signature for domain " + idServer) - } - - return retrieveAndVerify(idServer, idServerSignatures, marshalledBody) + // TODO: Check if the domain is part of a list of trusted ID servers + idServerSignatures, ok := signatures[idServer] + if !ok { + return errors.New("No signature for domain " + idServer) } - for domain, sigs := range signatures { - if err := retrieveAndVerify(domain, sigs, marshalledBody); err != nil { - return err - } - } - - return nil -} - -// retrieveAndVerify iterates over a given set of signatures and, for each of them, -// requests the corresponding public key to the identity server and verify the -// signature. -// Returns an error if the verification failed or if something went wrong in the -// process. -func retrieveAndVerify(domain string, signatures map[string]string, marshalledBody []byte) error { - for keyID := range signatures { - pubKey, err := queryIDServerPubKey(domain, keyID) + for keyID := range idServerSignatures { + pubKey, err := queryIDServerPubKey(idServer, keyID) if err != nil { return err } - if err = gomatrixserverlib.VerifyJSON(domain, gomatrixserverlib.KeyID(keyID), pubKey, marshalledBody); err != nil { + if err = gomatrixserverlib.VerifyJSON(idServer, gomatrixserverlib.KeyID(keyID), pubKey, marshalledBody); err != nil { return err } }