Commit f77712cf authored by ale's avatar ale
Browse files

Return a better error on GPG key identity mismatches

parent 05cf3588
Pipeline #30497 passed with stages
in 4 minutes and 33 seconds
......@@ -436,17 +436,23 @@ func parseOpenPGPKey(data []byte, email string) (key *crypto.Key, err error) {
return
}
// Verify that the key matches the user identity.
// Verify that the key matches the user identity. Try to
// return a nice error if this step fails.
entity := key.GetEntity()
var found bool
var identities []string
for _, identity := range entity.Identities {
identities = append(identities, identity.UserId.Email)
if identity.UserId.Email == email {
found = true
break
}
}
if !found {
err = errors.New("key identity does not match user")
err = fmt.Errorf(
"key identity (%s) does not match user %s",
strings.Join(identities, ", "),
email)
}
return
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment