Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Aug 29, 2023

In this PR:

  1. Updated notation verify error message to display failure reasons for each signature WITHOUT the need to enable -v or -d flags. This is to improve Notation CLI's usability during verification failures.
  2. Improved trust store related error messages readability.

This PR should only be reviewed/merged after its corresponding notation-go PR is merged: notaryproject/notation-go#345.

Based on discussions from issues #699, #700, and #701, the error messages become:

# no certificate in the trust store
$ notation verify testnotation.azurecr.io/alpine@sha256:93d5a28ff72d288d69b5997b8ba47396d2cbb62a72b5d87cd3351094b5d578a0
Error: failed to verify signature with digest sha256:f1356cb804623506ded33ecb78fe413a01ea1ce9b643b13456bf4ac7d2ff9698, no x509 certificates were found in trust store "alpine" of type "ca". Use command 'notation cert add' to create and add trusted certificates to the trust store.
Error: failed to verify signature with digest sha256:f7b98d8402ad46668884c73444b10ae787cbec882670303d4c1e733379eeab51, no x509 certificates were found in trust store "alpine" of type "ca". Use command 'notation cert add' to create and add trusted certificates to the trust store.
Error: signature verification failed for all the signatures associated with testnotation.azurecr.io/alpine@sha256:93d5a28ff72d288d69b5997b8ba47396d2cbb62a72b5d87cd3351094b5d578a0

# the trust store is missing
$ notation verify testnotation.azurecr.io/alpine@sha256:93d5a28ff72d288d69b5997b8ba47396d2cbb62a72b5d87cd3351094b5d578a0
Error: failed to verify signature with digest sha256:f1356cb804623506ded33ecb78fe413a01ea1ce9b643b13456bf4ac7d2ff9698, the trust store "alpine" of type "ca" doesn't exist. Use command 'notation cert add' to create and add trusted certificates to the trust store.
Error: failed to verify signature with digest sha256:f7b98d8402ad46668884c73444b10ae787cbec882670303d4c1e733379eeab51, the trust store "alpine" of type "ca" doesn't exist. Use command 'notation cert add' to create and add trusted certificates to the trust store.
Error: signature verification failed for all the signatures associated with testnotation.azurecr.io/alpine@sha256:93d5a28ff72d288d69b5997b8ba47396d2cbb62a72b5d87cd3351094b5d578a0

# no permission to read the certificate from the trust store
$ notation verify testnotation.azurecr.io/alpine@sha256:93d5a28ff72d288d69b5997b8ba47396d2cbb62a72b5d87cd3351094b5d578a0
Error: failed to verify signature with digest sha256:f1356cb804623506ded33ecb78fe413a01ea1ce9b643b13456bf4ac7d2ff9698, failed to read the trusted certificate "/home/patrickzheng/.config/notation/truststore/x509/ca/alpine/alpine.crt": open /home/patrickzheng/.config/notation/truststore/x509/ca/alpine/alpine.crt: permission denied
Error: failed to verify signature with digest sha256:f7b98d8402ad46668884c73444b10ae787cbec882670303d4c1e733379eeab51, failed to read the trusted certificate "/home/patrickzheng/.config/notation/truststore/x509/ca/alpine/alpine.crt": open /home/patrickzheng/.config/notation/truststore/x509/ca/alpine/alpine.crt: permission denied
Error: signature verification failed for all the signatures associated with testnotation.azurecr.io/alpine@sha256:93d5a28ff72d288d69b5997b8ba47396d2cbb62a72b5d87cd3351094b5d578a0

Patrick Zheng added 7 commits August 25, 2023 15:25
Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>
Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>
fix
Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>
Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>
Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>
Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>
Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>
@priteshbandi
Copy link
Contributor

IMO showing error or warning for each signature in a successful verification scenario is too much information which might confuse user.

@ghost
Copy link
Author

ghost commented Sep 4, 2023

IMO showing error or warning for each signature in a successful verification scenario is too much information which might confuse user.

@priteshbandi Yes, I agree. For a successful verification, none of the above error will be printed out.
On success, the output message of Notation CLI would just be:

$ notation verify testnotation.azurecr.io/hello@sha256:abcdef
Successfully verified signature for testnotation.azurecr.io/hello@sha256:abcdef

/cc: @yizha1 @FeynmanZhou

Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>
@codecov-commenter
Copy link

codecov-commenter commented Sep 14, 2023

Codecov Report

Merging #771 (aea48fe) into main (b7e5a6f) will increase coverage by 0.22%.
The diff coverage is 100.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##             main     #771      +/-   ##
==========================================
+ Coverage   63.98%   64.21%   +0.22%     
==========================================
  Files          40       40              
  Lines        2252     2266      +14     
==========================================
+ Hits         1441     1455      +14     
  Misses        689      689              
  Partials      122      122              
Files Changed Coverage Δ
cmd/notation/verify.go 87.07% <100.00%> (+1.36%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Patrick Zheng added 3 commits September 18, 2023 13:44
Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>
Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>
Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>
go.mod Outdated
golang.org/x/sys v0.12.0 // indirect
)

replace github.com/notaryproject/notation-go => github.com/Two-Hearts/notation-go v0.0.0-20230918074034-2606b29ba9dc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line need to be removed after merging notaryproject/notation-go#345

Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>
@ghost ghost requested a review from shizhMSFT September 19, 2023 07:09
Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but waiting for notaryproject/notation-go#345

@priteshbandi
Copy link
Contributor

# no certificate in the trust store
$ notation verify testnotation.azurecr.io/alpine@sha256:93d5a28ff72d288d69b5997b8ba47396d2cbb62a72b5d87cd3351094b5d578a0
Error: failed to verify signature with digest sha256:f1356cb804623506ded33ecb78fe413a01ea1ce9b643b13456bf4ac7d2ff9698, no x509 certificates were found in trust store "alpine" of type "ca". Use command 'notation cert add' to create and add trusted certificates to the trust store.
Error: failed to verify signature with digest sha256:f7b98d8402ad46668884c73444b10ae787cbec882670303d4c1e733379eeab51, no x509 certificates were found in trust store "alpine" of type "ca". Use command 'notation cert add' to create and add trusted certificates to the trust store.
Error: signature verification failed for all the signatures associated with testnotation.azurecr.io/alpine@sha256:93d5a28ff72d288d69b5997b8ba47396d2cbb62a72b5d87cd3351094b5d578a0

Ideal experience would be to not even retrieve signature if we know there are no certificates in trust store. Thus the error message becomes.

notation verify testnotation.azurecr.io/alpine@sha256:93d5a28ff72d288d69b5997b8ba47396d2cbb62a72b5d87cd3351094b5d578a0
Error: signature verification failed because no x509 certificates were found in trust store "alpine" of type "ca".

# the trust store is missing
$ notation verify testnotation.azurecr.io/alpine@sha256:93d5a28ff72d288d69b5997b8ba47396d2cbb62a72b5d87cd3351094b5d578a0
Error: failed to verify signature with digest sha256:f1356cb804623506ded33ecb78fe413a01ea1ce9b643b13456bf4ac7d2ff9698, the trust store "alpine" of type "ca" doesn't exist. Use command 'notation cert add' to create and add trusted certificates to the trust store.
Error: failed to verify signature with digest sha256:f7b98d8402ad46668884c73444b10ae787cbec882670303d4c1e733379eeab51, the trust store "alpine" of type "ca" doesn't exist. Use command 'notation cert add' to create and add trusted certificates to the trust store.
Error: signature verification failed for all the signatures associated with testnotation.azurecr.io/alpine@sha256:93d5a28ff72d288d69b5997b8ba47396d2cbb62a72b5d87cd3351094b5d578a0

Ditto, don't even retrieve signature if trust store is missing. Thus the error message becomes.

notation verify testnotation.azurecr.io/alpine@sha256:93d5a28ff72d288d69b5997b8ba47396d2cbb62a72b5d87cd3351094b5d578a0
Error: signature verification failed because the trust store "alpine" of type "ca" doesnot exist.

# no permission to read the certificate from the trust store
$ notation verify testnotation.azurecr.io/alpine@sha256:93d5a28ff72d288d69b5997b8ba47396d2cbb62a72b5d87cd3351094b5d578a0
Error: failed to verify signature with digest sha256:f1356cb804623506ded33ecb78fe413a01ea1ce9b643b13456bf4ac7d2ff9698, failed to read the trusted certificate "/home/patrickzheng/.config/notation/truststore/x509/ca/alpine/alpine.crt": open /home/patrickzheng/.config/notation/truststore/x509/ca/alpine/alpine.crt: permission denied
Error: failed to verify signature with digest sha256:f7b98d8402ad46668884c73444b10ae787cbec882670303d4c1e733379eeab51, failed to read the trusted certificate "/home/patrickzheng/.config/notation/truststore/x509/ca/alpine/alpine.crt": open /home/patrickzheng/.config/notation/truststore/x509/ca/alpine/alpine.crt: permission denied
Error: signature verification failed for all the signatures associated with testnotation.azurecr.io/alpine@sha256:93d5a28ff72d288d69b5997b8ba47396d2cbb62a72b5d87cd3351094b5d578a0

Ditto, don't even retrieve signature if notation cannot read certificate. Thus the error message becomes.

notation verify testnotation.azurecr.io/alpine@sha256:93d5a28ff72d288d69b5997b8ba47396d2cbb62a72b5d87cd3351094b5d578a0
Error: signature verification failed because unable to read the trusted certificate "/home/patrickzheng/.config/notation/truststore/x509/ca/alpine/alpine.crt": open /home/patrickzheng/.config/notation/truststore/x509/ca/alpine/alpine.crt: permission denied

@ghost
Copy link
Author

ghost commented Sep 23, 2023

@priteshbandi Thanks for the suggestion, but according to the Notary Project spec, signatures are verified before the signing identity. You could find the spec here, see the last question of FAQ.
This PR is for updating error messages only. If we want to change the verification workflow itself, then that should be another PR in notation-go.

@priteshbandi
Copy link
Contributor

@priteshbandi Thanks for the suggestion, but according to the Notary Project spec, signatures are verified before the signing identity. You could find the spec here, see the last question of FAQ. This PR is for updating error messages only. If we want to change the verification workflow itself, then that should be another PR in notation-go.

Opened issue to amend spec #790

@ghost ghost closed this Oct 27, 2023
Patrick Zheng added 3 commits October 27, 2023 11:23
Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>
Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>
Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>
@ghost ghost reopened this Oct 27, 2023
@ghost ghost closed this Oct 27, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants