-
Notifications
You must be signed in to change notification settings - Fork 619
Support self-managed keys when signing with sigstore-go #4368
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4368 +/- ##
==========================================
- Coverage 40.10% 34.32% -5.79%
==========================================
Files 155 217 +62
Lines 10044 15148 +5104
==========================================
+ Hits 4028 5199 +1171
- Misses 5530 9280 +3750
- Partials 486 669 +183 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6fa7574
to
072fbea
Compare
072fbea
to
020fda7
Compare
Verified this works with Rekor v2:
|
0b84033
to
927fffa
Compare
927fffa
to
6c5159e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM - I don't understand the IssueCertificateForExistingKey
part though.
cmd/cosign/cli/attest/attest_blob.go
Outdated
// Set to false so sigstore-go fetches the Fulcio certificate, | ||
// otherwise SignerFromKeyOpts would through the old signing path | ||
issueCertForKey := c.IssueCertificateForExistingKey | ||
c.IssueCertificateForExistingKey = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this code block. What flag to I pass to cosign attest-blob
to specify this behavior? Where does this get used by sigstore-go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we have too much duplication everywhere, I had missed adding --issue-certificate
to attest-blob
and attest
- I just added this.
For context, --issue-certificate
was added as part of https://blog.sigstore.dev/adopting-sigstore-incrementally-1b56a69b8c15/, to request a Fulcio certificate even if a key is provided.
This flag isn't used by sigstore-go, it's used by SignerFromKeyOpts
, which does a few things - it load a key from KMS/PIV/disk, it generates a key, and if IssueCertificateForExistingKey
is set or an ephemeral key was generated, it requests a certificate from Fulcio. This is the root cause of the issue, the method does too much.
sigstore-go will be handling certificate requests, so I need to set IssueCertificateForExistingKey
to false
to prevent SignerFromKeyOpts
from trying to generate a cert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhhh, okay, now I see. Still, mutating the configuration like this makes me a bit nervous (I've been bitten before in the cosign
code base doing similar things!)
The "problem" is that SignerFromKeyOpts
does two things:
- Constructs the
SignerVerifier
- Calls
keylessSigner
in some cases
There aren't that many places we call SignerFromKeyOpts
. Instead of mutating the config like this, would it make sense to have keylessSigner
become a public method and call it when needed from the cmd/cosign/cli
files? I'm not 100% sure if that's better or not, but I think it would allow us to avoid mutating the configuration like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I'm happy to try this out.
FYI @ret2libc, this would also solve the e2e test failure you were running into.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored this and then searched for method usage across GitHub and found it's being used in some libraries. So one of two options:
- Call this out in the CHANGELOG - we provide no guarantees for API breakages, and because the method signature has changed, it'll force clients to make an update
- Check if
SigningConfig
is set inSignerFromKeyOpts
- This is kinda gross
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think a CHANGELOG entry is just fine.
This creates a wrapper around the Keypair interface when a SignerVerifier is provided for signing with KMS or any other provided keys. This also retains support for --issue-certificate to request a certificate for a managed key. Fixes sigstore#4327 Signed-off-by: Hayden <[email protected]>
This is for uniformity with sign/sign-blob. Signed-off-by: Hayden <[email protected]>
c56b03d
to
f6a043d
Compare
Now, we can generate a SignerVerifier from a provided key without mandating that we also request a Fulcio certificate when "issue-certificate" is provided. Signed-off-by: Hayden <[email protected]>
f6a043d
to
6d27d43
Compare
} | ||
|
||
// TODO: Ideally SignerVerifier would return its configured hash. | ||
algo, err := signature.GetDefaultAlgorithmDetails(pubKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should use defaultLoadOptions = cosign.GetDefaultLoadOptions()
and pass defaultLoadOptions
to this method, to ensure that ed25519ph is used instead of ed25519.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me!
This creates a wrapper around the Keypair interface when a SignerVerifier is provided for signing with KMS or any other provided keys. This also retains support for --issue-certificate to request a certificate for a managed key.
Fixes #4327
Summary
Release Note
Documentation