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

unable to verify image using local certificate and local certificate chain #2826

Closed
choukri-m opened this issue Mar 22, 2023 · 4 comments
Closed
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@choukri-m
Copy link

Description

unable to verify an image using a local certificate and a local certificate chain. incorrectly raises the error: --certificate-identity or --certificate-identity-regexp is required for verification in keyless mode

to replicate this:

  1. sign an image and attach a certificate and a certificate chain, as per sigstore guidance
  2. verify the image using the same cert/cert chain, as per guidance (last example)

the output is as follows:

$ cosign verify --certificate cacert.pem --cert-chain ca-chain-bundle.cert.pem <image>
Error: --certificate-identity or --certificate-identity-regexp is required for verification in keyless mode
main.go:74: error during command execution: --certificate-identity or --certificate-identity-regexp is required for verification in keyless mode

i.e. The issue is that it assumes that I want a keyless verification as soon as it does not find a --key

Fix
the fix is very simple, refactor the code in the file: cmd/cosign/cli/verify/verify.go > Exec(...), line 100, to include a check for c.CertRef before checking the identity

i.e. it should be like this:

if c.KeyRef == "" && c.CertRef == "" {
	identities, err = c.Identities()
	if err != nil {
		return err
	}
}

Version

release cosign v2

@choukri-m choukri-m added the bug Something isn't working label Mar 22, 2023
@haydentherapper
Copy link
Contributor

We can't differentiate between when someone provides a certificate because they want "keyless" verification vs providing a certificate that only wraps a key without an identity. For Cosign 2.0, we've called out the latter use-case as no longer supported. We expect that certificates conform to the Fulcio certificate profile and that you'll need to provide an identity to verify the signature. If the certificate doesn't, then you should extract the certificate's key before verifying (using something like https://smallstep.com/docs/step-cli/reference/certificate/key to extract the key).

We'd like to tackle bring-your-own-PKI in a future release of Cosign to bring back support for this use-case while still preserving the identity requirements for identity-based certificates.

@choukri-m
Copy link
Author

Thanks for your response @haydentherapper

It seemed to work absolutely fine when I made the change I mentioned above and checked correctly an image that I signed with certs chain. Any reason why this is the case if this is not supported? the code for this check seems to still function as expected

@choukri-m
Copy link
Author

what is the down side for using it as I suggested?

@znewman01 znewman01 added the duplicate This issue or pull request already exists label Mar 22, 2023
@znewman01
Copy link
Contributor

what is the down side for using it as I suggested?

If somebody is using keyless signing with the public Fulcio instance, this means that verifiers will trust any identity—something we want to avoid. And the keyless use case is the primary purpose for cosign verify.

I'm marking as a duplicate of #2630 (we do want to fix this, but the UX is going to be a little more subtle).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants