Skip to content

Support custom ACME account key type.#7646

Open
ldlb9527 wants to merge 1 commit into
cert-manager:masterfrom
ldlb9527:feat-account-key
Open

Support custom ACME account key type.#7646
ldlb9527 wants to merge 1 commit into
cert-manager:masterfrom
ldlb9527:feat-account-key

Conversation

@ldlb9527
Copy link
Copy Markdown

@ldlb9527 ldlb9527 commented Mar 30, 2025

Pull Request Motivation

fixes: #7510

Kind

/kind feature

Release Note

Add a new parameter `keyType` to support specifying the key type for ACME account.

@cert-manager-prow cert-manager-prow Bot added dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. area/acme Indicates a PR directly modifies the ACME Issuer code labels Mar 30, 2025
@cert-manager-prow
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign jakexks for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@cert-manager-prow cert-manager-prow Bot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. area/api Indicates a PR directly modifies the 'pkg/apis' directory area/deploy Indicates a PR modifies deployment configuration needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 30, 2025
@cert-manager-prow
Copy link
Copy Markdown
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

@cert-manager-prow cert-manager-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 30, 2025
@Catman100
Copy link
Copy Markdown

Hello @ldlb9527 can you please add the Release Note Block to your MR?
Best regards

@wallrj wallrj requested a review from Copilot June 3, 2025 21:21
@wallrj
Copy link
Copy Markdown
Member

wallrj commented Jun 3, 2025

/ok-to-test

@cert-manager-prow cert-manager-prow Bot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 3, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread pkg/util/pki/generate.go
Comment on lines +226 to +239
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
Copy link

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider handling the error returned by x509.MarshalECPrivateKey rather than discarding it to avoid silent failures during EC private key marshalling.

Suggested change
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

Copilot uses AI. Check for mistakes.
exponent = 0

default:
return stableOptions{}
Copy link

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
return stableOptions{}
return stableOptions{}, errors.New("unsupported crypto.Signer type")

Copilot uses AI. Check for mistakes.
@ldlb9527
Copy link
Copy Markdown
Author

ldlb9527 commented Jun 4, 2025

I will try to handle failed jobs. Please let me know if you find any problems with the code.

@cert-manager-prow cert-manager-prow Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 5, 2025
@ldlb9527 ldlb9527 force-pushed the feat-account-key branch from 6f2b738 to 5167900 Compare June 7, 2025 18:02
@cert-manager-prow cert-manager-prow Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jun 7, 2025
@ldlb9527 ldlb9527 force-pushed the feat-account-key branch 2 times, most recently from 91e3f15 to eaf496e Compare June 7, 2025 18:36
@cert-manager-prow cert-manager-prow Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 9, 2025
@Catman100
Copy link
Copy Markdown

Hello @ldlb9527,
is there a status update for the Issue?

@cert-manager-prow cert-manager-prow Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 22, 2025
Signed-off-by: xiong.chen <1249843194@qq.com>
@ldlb9527
Copy link
Copy Markdown
Author

Hello @Catman100 , I have rebased my changes on the latest code.

@Catman100
Copy link
Copy Markdown

Hi, is there any change? Greetings

@ldlb9527
Copy link
Copy Markdown
Author

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?

@Catman100
Copy link
Copy Markdown

@inteon @erikgb can you check this Request please. Thanks for your Time

@cert-manager-prow cert-manager-prow Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 23, 2025
@cert-manager-prow
Copy link
Copy Markdown
Contributor

PR needs rebase.

Details

Instructions 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.

@cert-manager-prow
Copy link
Copy Markdown
Contributor

@ldlb9527: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cert-manager-master-e2e-v1-35-upgrade 097829c link true /test pull-cert-manager-master-e2e-v1-35-upgrade

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.

Details

Instructions 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.

@marie-j
Copy link
Copy Markdown

marie-j commented Jan 20, 2026

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/acme Indicates a PR directly modifies the ACME Issuer code area/api Indicates a PR directly modifies the 'pkg/apis' directory area/deploy Indicates a PR modifies deployment configuration dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Key Size for Acme Account Key

5 participants