diff --git a/policy/policy.go b/policy/policy.go index 753186a2..5ab2408e 100644 --- a/policy/policy.go +++ b/policy/policy.go @@ -76,20 +76,19 @@ func (p Policy) PublicKeyVerifiers(ko map[string][]func(signer.SignerProvider) ( } } - kspv, ok := vp.(*kms.KMSSignerProvider) - if !ok { - return nil, fmt.Errorf("provided verifier provider is not a KMS verifier provider") + if vp != nil { + var ok bool + ksp, ok = vp.(*kms.KMSSignerProvider) + if !ok { + return nil, fmt.Errorf("provided verifier provider is not a KMS verifier provider") + } } - verifier, err = kspv.Verifier(context.TODO()) + verifier, err = ksp.Verifier(context.TODO()) if err != nil { return nil, fmt.Errorf("failed to create kms verifier: %w", err) } - if err != nil { - return nil, fmt.Errorf("KMS Key ID recognized but not valid: %w", err) - } - } } diff --git a/policy/policy_test.go b/policy/policy_test.go index c57fda3e..761237c5 100644 --- a/policy/policy_test.go +++ b/policy/policy_test.go @@ -31,6 +31,7 @@ import ( "github.com/in-toto/go-witness/attestation/commandrun" "github.com/in-toto/go-witness/cryptoutil" "github.com/in-toto/go-witness/intoto" + "github.com/in-toto/go-witness/signer" "github.com/in-toto/go-witness/source" "github.com/invopop/jsonschema" "github.com/stretchr/testify/assert" @@ -483,7 +484,7 @@ func TestPubKeyVerifiers(t *testing.T) { } } - verifiers, err := p.PublicKeyVerifiers() + verifiers, err := p.PublicKeyVerifiers(map[string][]func(signer.SignerProvider) (signer.SignerProvider, error){}) if testCase.expectedErr == nil { assert.NoError(t, err) assert.Len(t, verifiers, testCase.expectedLen)