mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-16 18:35:03 -06:00
plugin/discovery: Add friendly gpg err msg
When GPG verification fails, display a helpful message to the user instead of the generic openpgp error.
This commit is contained in:
parent
9a8a74b9bb
commit
06825bf46d
@ -27,6 +27,12 @@ import (
|
|||||||
|
|
||||||
const protocolVersionHeader = "x-terraform-protocol-version"
|
const protocolVersionHeader = "x-terraform-protocol-version"
|
||||||
|
|
||||||
|
const gpgVerificationError = `GPG signature verification error:
|
||||||
|
Terraform was unable to verify the GPG signature of the downloaded provider
|
||||||
|
files using the keys downloaded from the Terraform Registry. This may mean that
|
||||||
|
the publisher of the provider removed the key it was signed with, or that the
|
||||||
|
distributed files were changed after this version was released.`
|
||||||
|
|
||||||
var httpClient *http.Client
|
var httpClient *http.Client
|
||||||
|
|
||||||
var errVersionNotFound = errors.New("version not found")
|
var errVersionNotFound = errors.New("version not found")
|
||||||
@ -369,13 +375,14 @@ func (i *ProviderInstaller) getProviderChecksum(urls *response.TerraformProvider
|
|||||||
asciiArmor := urls.SigningKeys.GPGASCIIArmor()
|
asciiArmor := urls.SigningKeys.GPGASCIIArmor()
|
||||||
signer, err := verifySig(shasums, signature, asciiArmor)
|
signer, err := verifySig(shasums, signature, asciiArmor)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
log.Printf("[ERROR] error verifying signature: %s", err)
|
||||||
|
return "", fmt.Errorf(gpgVerificationError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display identity for GPG key which succeeded verifying the signature.
|
// Display identity for GPG key which succeeded verifying the signature.
|
||||||
// This could also be used to display to the user with i.Ui.Info().
|
// This could also be used to display to the user with i.Ui.Info().
|
||||||
identities := []string{}
|
identities := []string{}
|
||||||
for k, _ := range signer.Identities {
|
for k := range signer.Identities {
|
||||||
identities = append(identities, k)
|
identities = append(identities, k)
|
||||||
}
|
}
|
||||||
identity := strings.Join(identities, ", ")
|
identity := strings.Join(identities, ", ")
|
||||||
|
Loading…
Reference in New Issue
Block a user