You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears that when using a Virtual PKCS#11 Token, such as those provided by service providers like DigiCert to communicate with a Hardware Security Module (HSM), cosign does not push the public key to Rekor. Instead the full public certificate is stored, which confuses cosign on verification on the image consumer's end.
It seems to stem from this area of the code where, if the public certificate is available, the public certificate is uploaded to Rekor instead of the public key:
// Upload the cert or the public key, depending on what we have
Granted, the error message makes sense: validating against Rekor doesn't work because a public key is being compared to a public certificate. However, we don't want to require consumers of our images to have the full public certificate, and it doesn't seem clear how that would work.
Disabling Rekor on both ends (--tlog-upload=false on signing and insecure-ignore-tlog=true on verification) works. However we don't want to do that if we don't have to, and the insecure messages will lead to more questions by our image consumers.
I admit this may be user error somewhere, so any guidance on how to have customers validate with the public signature would be appreciated.
Thanks!
How to reproduce
Use cosign Sign an image using a Virtual PKCS#11 Token:
$ cosign sign \
--key "pkcs11:token=Virtual%20PKCS%2311%20Token;slot-id=0;id=<id>;object=<object>?module-path=/usr/local/lib/smpkcs11.so&pin-value=anything" \
$IMAGE_DIGEST
WARNING: "<repository>" appears to be a private repository, please confirm uploading to the transparency log at "https://rekor.sigstore.dev"
Are you sure you would like to continue? [y/N] y
The sigstore service, hosted by sigstore a Series of LF Projects, LLC, is provided pursuant to the Hosted Project Tools Terms of Use, available at https://lfprojects.org/policies/hosted-project-tools-terms-of-use/.
Note that if your submission includes personal data associated with this signed artifact, it will be part of an immutable record.
This may include the email address associated with the account with which you authenticate your contractual Agreement.
This information will be used forsigning this artifact and will be storedin public transparency logs and cannot be removed later, and is subject to the Immutable Record notice at https://lfprojects.org/policies/hosted-project-tools-immutable-records/.
By typing 'y', you attest that (1) you are not submitting the personal data of any other person; and (2) you understand and agree to the statement and the Agreement terms at the URLs listed above.
Are you sure you would like to continue? [y/N] y
tlog entry created with index: <index>
Pushing signature to: <repository>
Use cosign to verify using same Virtual PKCS#11 Token:
$ cosign verify \
--key "pkcs11:token=Virtual%20PKCS%2311%20Token;slot-id=0;id=<id>;object=<object>?module-path=/usr/local/lib/smpkcs11.so&pin-value=anything" \
$IMAGE_DIGEST
Error: no matching signatures: error verifying bundle: comparing public key PEMs, expected -----BEGIN PUBLIC KEY-----
<PUBLIC KEY>
-----END PUBLIC KEY-----
, got -----BEGIN CERTIFICATE-----
<PUBLIC CERTIFICATE>
-----END CERTIFICATE-----
main.go:69: error during command execution: no matching signatures: error verifying bundle: comparing public key PEMs, expected -----BEGIN PUBLIC KEY-----
<PUBLIC KEY>
-----END PUBLIC KEY-----
, got -----BEGIN CERTIFICATE-----
<PUBLIC CERTIFICATE>
-----END CERTIFICATE-----
Exporting the public key and attempting to verify on it directly has the same result:
$ cosign verify --key ExportedPublicKey.pub $IMAGE_DIGEST
Error: no matching signatures: error verifying bundle: comparing public key PEMs, expected -----BEGIN PUBLIC KEY-----
<PUBLIC KEY>
-----END PUBLIC KEY-----
, got -----BEGIN CERTIFICATE-----
<PUBLIC CERTIFICATE>
-----END CERTIFICATE-----
main.go:69: error during command execution: no matching signatures: error verifying bundle: comparing public key PEMs, expected -----BEGIN PUBLIC KEY-----
<PUBLIC KEY>
-----END PUBLIC KEY-----
, got -----BEGIN CERTIFICATE-----
<PUBLIC CERTIFICATE>
-----END CERTIFICATE-----
Description
Overview
It appears that when using a Virtual PKCS#11 Token, such as those provided by service providers like DigiCert to communicate with a Hardware Security Module (HSM), cosign does not push the public key to Rekor. Instead the full public certificate is stored, which confuses cosign on verification on the image consumer's end.
It seems to stem from this area of the code where, if the public certificate is available, the public certificate is uploaded to Rekor instead of the public key:
cosign/internal/pkg/cosign/rekor/signer.go
Line 77 in 173f547
Granted, the error message makes sense: validating against Rekor doesn't work because a public key is being compared to a public certificate. However, we don't want to require consumers of our images to have the full public certificate, and it doesn't seem clear how that would work.
Disabling Rekor on both ends (
--tlog-upload=false
on signing andinsecure-ignore-tlog=true
on verification) works. However we don't want to do that if we don't have to, and the insecure messages will lead to more questions by our image consumers.I admit this may be user error somewhere, so any guidance on how to have customers validate with the public signature would be appreciated.
Thanks!
How to reproduce
Use cosign Sign an image using a Virtual PKCS#11 Token:
Use cosign to verify using same Virtual PKCS#11 Token:
Exporting the public key and attempting to verify on it directly has the same result:
Version
Version of ubuntu and cosign
The text was updated successfully, but these errors were encountered: