Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix verification of subkeys of default gpg key #11713

Next Next commit
Fix verification of subkeys of default gpg key
Fix #10309

Signed-off-by: Andrew Thornton <[email protected]>
  • Loading branch information
zeripath committed May 31, 2020
commit aa87d5ecdcc1b735834af5a9f73e077f3a6e7e72
17 changes: 17 additions & 0 deletions models/gpg_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,8 @@ func verifyWithGPGSettings(gpgSettings *git.GPGSettings, sig *packet.Signature,
return commitVerification
}

log.Info("PublicKeyContent: %s", gpgSettings.PublicKeyContent)
zeripath marked this conversation as resolved.
Show resolved Hide resolved

zeripath marked this conversation as resolved.
Show resolved Hide resolved
// Otherwise we have to parse the key
ekey, err := checkArmoredGPGKeyString(gpgSettings.PublicKeyContent)
if err != nil {
Expand All @@ -741,6 +743,21 @@ func verifyWithGPGSettings(gpgSettings *git.GPGSettings, sig *packet.Signature,
CanSign: pubkey.CanSign(),
KeyID: pubkey.KeyIdString(),
}
for _, subKey := range ekey.Subkeys {
content, err := base64EncPubKey(subKey.PublicKey)
if err != nil {
return &CommitVerification{
CommittingUser: committer,
Verified: false,
Reason: "gpg.error.generate_hash",
}
}
k.SubsKey = append(k.SubsKey, &GPGKey{
Content: content,
CanSign: subKey.PublicKey.CanSign(),
KeyID: subKey.PublicKey.KeyIdString(),
})
}
if commitVerification := hashAndVerifyWithSubKeys(sig, payload, k, committer, &User{
Name: gpgSettings.Name,
Email: gpgSettings.Email,
Expand Down