Repository navigation
fix(sign): sign Helm charts with the KMS key again - #431
cert-manager-prow[bot] merged 1 commit into
Conversation
|
Skipping CI for Draft Pull Request. |
wallrj-cyberark
left a comment
There was a problem hiding this comment.
Notes for reviewers on the two places where the change is not obvious from the diff.
| // > // supports both *rsa.PrivateKey and crypto.Signer | ||
| return &openpgp.Entity{ | ||
| PrimaryKey: publicKey, | ||
| PrivateKey: &packet.PrivateKey{ |
There was a problem hiding this comment.
The old code set PubKeyAlgo and KeyId on the private key after NewSignerPrivateKey, to work around key IDs not matching. Copying *publicKey into the packet gives it the same algorithm and key ID as PrimaryKey, so both lines are no longer needed. The test checks this: verification looks the key up by the signature's issuer key ID.
|
|
||
| // publicEntity returns the public half of entity with a self-signed identity, | ||
| // which go-crypto needs before it will use the key to verify. | ||
| func publicEntity(t *testing.T, entity *openpgp.Entity) *openpgp.Entity { |
There was a problem hiding this comment.
This repeats the identity self-signing from BootstrapPGPFromGCP. go-crypto will not use a key to verify without a self-signed identity. I kept it in the test rather than refactoring BootstrapPGPFromGCP, to keep this fix small.
- `cmrel sign helm` panics with "openpgp: unknown signer type in NewSignerPrivateKey" since the move to ProtonMail/go-crypto for Helm v4. That function only accepts in-memory private key types, and the KMS signer is not one of them. - Build the private key packet by hand instead. go-crypto's RSA signing already accepts any crypto.Signer. - `cmrel gcb bootstrap-pgp` reaches the same code, and would then print a public key with no identity signature: go-crypto serializes `Identity.Signatures`, not `SelfSignature`. Set both. - Log KMS signing errors in kmssigner, because go-crypto drops the error returned by an RSA crypto.Signer. - Add a test that bootstraps a key and signs a chart with a stand-in KMS signer, then verifies the chart with helm using only the armored public key. It fails without either fix. Signed-off-by: Richard Wall <[email protected]> Co-Authored-By: Claude <[email protected]>
53fe37f to
612096c
Compare
wallrj-cyberark
left a comment
There was a problem hiding this comment.
Updated after a review pass. cmrel gcb bootstrap-pgp now writes the identity signature, KMS errors are logged, and the test now checks the whole path: it bootstraps the key, signs a chart, and verifies it with helm using only the armored key. My earlier inline comments are about the previous commit and no longer apply.
|
This fix worked against the real KMS key in the v1.22.0-alpha.0 release. Staging signed the chart with it, and We tested it stacked with #376 and #377, so this shows the three work together. Evidence from the releaseThe first tag-triggered build used cert-manager's own
What this release did not test
[with Claude] |
SgtCoDFish
left a comment
There was a problem hiding this comment.
/lgtm
/approve
My main reaction is "if it works it works" and there's not much to review here.
Given the general rubbishness of PGP I look at this and think "should we just drop helm chart signatures altogether so we don't have to deal with this any more"... but I guess the signing hasn't really needed much maintenance since I wrote it and a little maintenance is fine - as such, approving.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: SgtCoDFish The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
cmrel sign helmcannot sign with the KMS key, so no cert-manager build frommastercan be staged. This PR fixes it.The
v1.22.0-alpha.0staging build failed while creating the chart's.provfile:Why it broke
pkg/signfromgolang.org/x/crypto/openpgptoProtonMail/go-crypto.packet.NewSignerPrivateKeyonly accepts in-memory RSA, ECDSA and EdDSA private keys. It panics on any othercrypto.Signer, including our KMS signer.masterhas used cmrel v1.13.0 since the makefile-modules update on 13 September.release-1.21andrelease-1.20still use a 2024 cmrel, which is why v1.21.3 and v1.20.5 built.v1.22.0-alpha.0is the first build frommastersince then.What changes
deriveEntitybuilds the private key packet by hand. go-crypto's RSA signing already accepts anycrypto.Signer(signature.go#L1003-L1004). ThePubKeyAlgoandKeyIdfix-ups are no longer needed, because both come from the copied public key.cmrel gcb bootstrap-pgpnow writes a usable public key. It reaches the same code, so it panicked too. Without a second change it would print a key with no identity signature, because go-crypto serializesIdentity.Signatures, notSelfSignature(keys.go#L798). The identity code moves intoaddSelfSignedIdentity, which sets both.crypto.Signer(itserris redeclared inside thecase), so a failed KMS call would otherwise only show up later as a missing signature.HelmChartandBootstrapPGPFromGCPare split so that the parts after KMS can be tested.What we want from you
Please review. After it merges, we will tag v1.13.1, point cert-manager
masterat it, and use it forv1.22.0-alpha.1(cert-manager/cert-manager#9553).How this was tested, and what it does not prove
TestBootstrapKeyVerifiesSignedChartuses a stand-in KMS signer: acrypto.Signerthat only accepts SHA-512 digests, like the real key. It bootstraps the armored public key, signs a packaged chart, then verifies the chart with Helm'sVerify, using only the armored key.NewSignerPrivateKeyput back, the test fails with the same panic as the staging build.Signaturesline, it fails withopenpgp: invalid data: v4 entity without any identities.make test,go vet ./...andgofmtpass.v1.22.0-alpha.1staging build.[with Claude]