diff --git a/cmd/notation/verify.go b/cmd/notation/verify.go index a1cbd3e3f..29aa9efae 100644 --- a/cmd/notation/verify.go +++ b/cmd/notation/verify.go @@ -16,6 +16,7 @@ package main import ( "errors" "fmt" + "io/fs" "os" "reflect" @@ -158,12 +159,13 @@ func checkVerificationFailure(outcomes []*notation.VerificationOutcome, printOut // write out on failure if err != nil { for _, outcome := range outcomes { - fmt.Fprintf(os.Stderr, "Error: Failed to verify signature with digest %v, ", outcome.SignatureManifestDescriptor.Digest) - var errorNonExistence truststore.ErrorNonExistence - if errors.As(outcome.Error, &errorNonExistence) { - fmt.Fprintf(os.Stderr, "%s. Use command 'notation cert add' to create and add trusted certificates to the trust store.\n", errorNonExistence) + var errTrustStore truststore.ErrorTrustStore + var errCertificate truststore.ErrorCertificate + if (errors.As(outcome.Error, &errTrustStore) && errors.Is(errTrustStore, fs.ErrNotExist)) || + (errors.As(outcome.Error, &errCertificate) && errors.Is(errCertificate, fs.ErrNotExist)) { + fmt.Fprintf(os.Stderr, "Error: %v. Use command 'notation cert add' to create and add trusted certificates to the trust store.\n", outcome.Error) } else { - fmt.Fprintln(os.Stderr, outcome.Error) + fmt.Fprintf(os.Stderr, "Error: %v\n", outcome.Error) } } var errorVerificationFailed notation.ErrorVerificationFailed diff --git a/go.mod b/go.mod index c5f6f0529..365790a6f 100644 --- a/go.mod +++ b/go.mod @@ -30,4 +30,4 @@ require ( golang.org/x/sys v0.11.0 // indirect ) -replace github.com/notaryproject/notation-go => github.com/Two-Hearts/notation-go v0.0.0-20230829013913-fcd8ca6c4475 +replace github.com/notaryproject/notation-go => github.com/Two-Hearts/notation-go v0.0.0-20230830040707-06b9ea427f0e diff --git a/go.sum b/go.sum index 0445b7469..9f3092aed 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 h1:mFRzDkZVAjdal+s7s0MwaRv9igoPqLRdzOLzw/8Xvq8= github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU= -github.com/Two-Hearts/notation-go v0.0.0-20230829013913-fcd8ca6c4475 h1:U4v/Olg4RhrsmkVXuQt7ecvrvE7saactrvA86ahHaFs= -github.com/Two-Hearts/notation-go v0.0.0-20230829013913-fcd8ca6c4475/go.mod h1:nk9Wa8cwIkpajw3J+2axNzk/bOuIGa446gTyjjbalWs= +github.com/Two-Hearts/notation-go v0.0.0-20230830040707-06b9ea427f0e h1:CS85l8f1kPkq5uwfFLtLl9kLK16RfoeepSR2jnZqA3U= +github.com/Two-Hearts/notation-go v0.0.0-20230830040707-06b9ea427f0e/go.mod h1:nk9Wa8cwIkpajw3J+2axNzk/bOuIGa446gTyjjbalWs= github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74 h1:Kk6a4nehpJ3UuJRqlA3JxYxBZEqCeOmATOvrbT4p9RA= github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=