Support custom ACME account key type.#7646
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @ldlb9527. Thanks for your PR. I'm waiting for a cert-manager member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Hello @ldlb9527 can you please add the Release Note Block to your MR? |
|
/ok-to-test |
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for a custom ACME account key type by introducing a new parameter “keyType” and updating the codebase to use the generic crypto.Signer interface rather than a specific RSA implementation. It also updates tests, API type definitions, and CRDs to reflect this change.
- Updated ACME key generation with key type support and error handling improvements.
- Modified function signatures and type conversions to use crypto.Signer across the codebase.
- Adjusted API conversions and CRD definitions to include the new keyType field.
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/util/pki/generate.go | Introduced MarshalPrivateKey using crypto.Signer |
| pkg/issuer/acme/setup_test.go | Updated test mocks to use crypto.Signer instead of *rsa.PrivateKey |
| pkg/issuer/acme/setup.go | Adjusted key creation and client registration to use crypto.Signer |
| pkg/apis/acme/v1/types_issuer.go | Added keyType field to ACMEIssuer schema |
| pkg/acme/accounts/test/registry.go | Updated FakeRegistry function signatures for crypto.Signer |
| pkg/acme/accounts/registry.go | Refactored client registry to support crypto.Signer in stableOptions |
| pkg/acme/accounts/client.go | Updated client creation function signature for crypto.Signer |
| internal/apis/acme/v1/zz_generated.conversion.go | Included keyType conversion |
| internal/apis/acme/types_issuer.go | Added keyType field in internal ACMEIssuer type |
| deploy/crds/crd-issuers.yaml | Documented new keyType field in issuer CRD |
| deploy/crds/crd-clusterissuers.yaml | Documented new keyType field in cluster issuer CRD |
| func MarshalPrivateKey(privateKey crypto.Signer) []byte { | ||
| if privateKey == nil { | ||
| return nil | ||
| } | ||
| var privateKeyBytes []byte | ||
| switch privateKey.(type) { | ||
| case *rsa.PrivateKey: | ||
| privateKeyBytes = x509.MarshalPKCS1PrivateKey(privateKey.(*rsa.PrivateKey)) | ||
| case *ecdsa.PrivateKey: | ||
| privateKeyBytes, _ = x509.MarshalECPrivateKey(privateKey.(*ecdsa.PrivateKey)) | ||
| default: | ||
| return nil | ||
| } | ||
| return privateKeyBytes |
There was a problem hiding this comment.
Consider handling the error returned by x509.MarshalECPrivateKey rather than discarding it to avoid silent failures during EC private key marshalling.
| func MarshalPrivateKey(privateKey crypto.Signer) []byte { | |
| if privateKey == nil { | |
| return nil | |
| } | |
| var privateKeyBytes []byte | |
| switch privateKey.(type) { | |
| case *rsa.PrivateKey: | |
| privateKeyBytes = x509.MarshalPKCS1PrivateKey(privateKey.(*rsa.PrivateKey)) | |
| case *ecdsa.PrivateKey: | |
| privateKeyBytes, _ = x509.MarshalECPrivateKey(privateKey.(*ecdsa.PrivateKey)) | |
| default: | |
| return nil | |
| } | |
| return privateKeyBytes | |
| func MarshalPrivateKey(privateKey crypto.Signer) ([]byte, error) { | |
| if privateKey == nil { | |
| return nil, fmt.Errorf("private key is nil") | |
| } | |
| var privateKeyBytes []byte | |
| var err error | |
| switch privateKey.(type) { | |
| case *rsa.PrivateKey: | |
| privateKeyBytes = x509.MarshalPKCS1PrivateKey(privateKey.(*rsa.PrivateKey)) | |
| case *ecdsa.PrivateKey: | |
| privateKeyBytes, err = x509.MarshalECPrivateKey(privateKey.(*ecdsa.PrivateKey)) | |
| if err != nil { | |
| return nil, fmt.Errorf("failed to marshal ECDSA private key: %w", err) | |
| } | |
| default: | |
| return nil, fmt.Errorf("unsupported private key type: %T", privateKey) | |
| } | |
| return privateKeyBytes, nil |
| exponent = 0 | ||
|
|
||
| default: | ||
| return stableOptions{} |
There was a problem hiding this comment.
In newStableOptions, the default case silently returns an empty stableOptions. Consider explicitly handling unsupported crypto.Signer types, for example by returning an error or logging a warning, to make the failure mode clearer.
| return stableOptions{} | |
| return stableOptions{}, errors.New("unsupported crypto.Signer type") |
|
I will try to handle failed jobs. Please let me know if you find any problems with the code. |
6f2b738 to
5167900
Compare
91e3f15 to
eaf496e
Compare
|
Hello @ldlb9527, |
eaf496e to
bd5136d
Compare
bd5136d to
acbbe4f
Compare
Signed-off-by: xiong.chen <1249843194@qq.com>
acbbe4f to
097829c
Compare
|
Hello @Catman100 , I have rebased my changes on the latest code. |
|
Hi, is there any change? Greetings |
|
Hi @wallrj , I see @Catman100 has been following up. Could you confirm if this feature (custom ACME account key type) is something the team wants to support? |
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@ldlb9527: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
Hello @ldlb9527 Do you need a hand on this topic ? I am willing to help you on this matter to get this contribution moved forward if needed |
Pull Request Motivation
fixes: #7510
Kind
/kind feature
Release Note