Skip to content

fixes #7506: enable configurable max key/cert sizes, defaulting to original safe values introduced in #7401#7642

Merged
cert-manager-prow[bot] merged 5 commits intocert-manager:masterfrom
robertlestak:configurable-pem-size
Feb 11, 2026
Merged

fixes #7506: enable configurable max key/cert sizes, defaulting to original safe values introduced in #7401#7642
cert-manager-prow[bot] merged 5 commits intocert-manager:masterfrom
robertlestak:configurable-pem-size

Conversation

@robertlestak
Copy link
Copy Markdown

@robertlestak robertlestak commented Mar 27, 2025

Pull Request Motivation

While 'non-standard', there are valid technical situations where a key/pem would be expected to exceed the 'safe' values implemented in #7401.

Issue #7506 shows that multiple users are facing this issue.

This PR enables operators to override the default values in the controller configuration. "Default" usage will continue to use the values implemented in #7401, but for operators who need higher max values, they can set those on a per-deployment basis.

  • Added PEMSizeLimitsConfig with four configurable parameters:
    • MaxCertificateSize: Maximum bytes for individual certificates (default: 6,500)
    • MaxPrivateKeySize: Maximum bytes for private keys (default: 13,000)
    • MaxChainLength: Maximum certificates in a chain (default: 10)
    • MaxBundleSize: Maximum bytes for certificate bundles (default: 330,000)

Kind

/kind bug feature

Release Note

Added support for configuring PEM decoding size limits, allowing operators to handle larger certificates and keys.

@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. kind/bug Categorizes issue or PR as related to a bug. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/feature Categorizes issue or PR as related to a new feature. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 27, 2025
@cert-manager-prow
Copy link
Copy Markdown
Contributor

Hi @robertlestak. 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 27, 2025
@robertlestak robertlestak force-pushed the configurable-pem-size branch from f5b7c90 to d9134c0 Compare March 27, 2025 18:37
@ThatsMrTalbot
Copy link
Copy Markdown
Contributor

👋 Hiya @robertlestak

I'm not sure we would want this configured via environment variables, all other cert-manager config is done via flags or via the config file.

@robertlestak
Copy link
Copy Markdown
Author

@ThatsMrTalbot no worries, i didn't want to overstep in changing too much, i'll modify to use config file and push update later today!

@arjun-beathi
Copy link
Copy Markdown

+1 waiting for this feature.

@alter3go
Copy link
Copy Markdown

+1 also looking forward to this due to #7506. Thanks for taking this on, @robertlestak!

@robertlestak robertlestak force-pushed the configurable-pem-size branch from d9134c0 to 8bd4396 Compare June 12, 2025 22:05
@cert-manager-prow cert-manager-prow bot added area/api Indicates a PR directly modifies the 'pkg/apis' directory area/deploy Indicates a PR modifies deployment configuration area/testing Issues relating to testing size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 12, 2025
@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 Jul 10, 2025
…iginal safe values introduced in #7401

Signed-off-by: robertlestak <robert.lestak@umusic.com>
@robertlestak robertlestak force-pushed the configurable-pem-size branch from 8bd4396 to ba61c53 Compare July 10, 2025 17:45
@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 10, 2025
@ThatsMrTalbot
Copy link
Copy Markdown
Contributor

/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 Jul 11, 2025
@SgtCoDFish
Copy link
Copy Markdown
Member

@ThatsMrTalbot brought this to my attention in standup this morning. For my 2 cents, I'm totally fine with increasing the max size limits across the board with no need for configuration (for context, I wrote the PR adding these limits to fix a security issue and the current limits are my best guesses)

We're already prepared for certs to grow much (much) larger with post-quantum signatures and we'd need to bump the size limits for that at some point anyway! If you were able to provide examples of the cert chains you're talking about which exceed these size limits, I'd be comfortable with increasing the limits accordingly.

(I understand that certs can have private org data in them, so you could just provide the size in bytes of a cert + the max number of certs in a chain that you see if you're not comfortable sharing the actual certs!)

@robertlestak
Copy link
Copy Markdown
Author

@SgtCoDFish Ack my use case may be "non-standard" but certainly not unique. Due to reasons out of scope of cert-manager, I have business use cases where a single cert can have >250 SANs on it.

This is with "conventional" public CA+Intermediate (eg Sectigo, DigiCert, etc) - so the majority of the "size" comes from the leaf w/ over 200 SANs. I would hesitate to say "X bytes should suffice", since business case is dynamic and while i have 250 SANs today, I had ~150 last year, and may have ~350 next year.

For highly regulated environments managed entirely through IaC, any manifest changes must first go through layers of review/approval, and are gated with granular RBAC preventing even operators from performing certain actions. If I have a user with the ability to create secrets/certs inside my environment, I've got much bigger issues than theoretical DoS of cluster-local cert-manager pod. However recognizing it is a real potential risk and some environments may not be as restrictive, I would like to default "safe" and require "opt-in" for increased chain length support.

@SgtCoDFish
Copy link
Copy Markdown
Member

Thank you for the context, that's really helpful! I did a bit of digging and I saw that adding about 10 longish example DNS names (e.g. service85.subdomain85.example85.com) adds about 600 bytes, so I'm guessing that with 350 domain names we're looking at very large certs.

I think it's fair to say that it'd be hard for us to anticipate how these size limits might need to grow. You've convinced me that configurable size limits are worthwhile!

Configurable size limits probably aren't likely to be backported, though - so the soonest they'd be usable would be with cert-manager 1.19 in early Oct (or in an alpha/beta release done before that).

I'm on paternity leave for 2 months starting next week, so I won't be able to review this and drive it through, but I'd encourage you to chase for reviews in #cert-manager-dev on slack once tests are passing!

@robertlestak robertlestak force-pushed the configurable-pem-size branch from c9a357b to fc37bc5 Compare February 2, 2026 17:07
- Resolved conflicts between PEM size limits and CertificateRequestMinimumBackoffDuration
- Fixed MaxChainLength semantics (bytes not count)
- Updated Helm chart documentation and schema
- Fixed validation logic
- Added missing test imports
- All tests passing

Signed-off-by: robert lestak <robert.lestak@umusic.com>
@robertlestak robertlestak force-pushed the configurable-pem-size branch 2 times, most recently from 27c2221 to 463f848 Compare February 2, 2026 22:58
@cert-manager-prow cert-manager-prow bot added dco-signoff: no Indicates that at least one commit in this pull request is missing the DCO sign-off message. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 2, 2026
@robertlestak robertlestak force-pushed the configurable-pem-size branch from 463f848 to 27c2221 Compare February 2, 2026 22:59
@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. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed dco-signoff: no Indicates that at least one commit in this pull request is missing the DCO sign-off message. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 2, 2026
@robertlestak robertlestak force-pushed the configurable-pem-size branch from 27c2221 to 65cb1f0 Compare February 2, 2026 23:00
@cert-manager-prow cert-manager-prow bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 2, 2026
@robertlestak robertlestak force-pushed the configurable-pem-size branch from 65cb1f0 to 27c2221 Compare February 2, 2026 23:01
@cert-manager-prow cert-manager-prow bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 2, 2026
@cert-manager-prow
Copy link
Copy Markdown
Contributor

cert-manager-prow bot commented Feb 2, 2026

@robertlestak: The following tests 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-33 ba61c53 link true /test pull-cert-manager-master-e2e-v1-33
pull-cert-manager-master-e2e-v1-33-upgrade ba61c53 link true /test pull-cert-manager-master-e2e-v1-33-upgrade
pull-cert-manager-master-e2e-v1-34-upgrade ba61c53 link true /test pull-cert-manager-master-e2e-v1-34-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.

@robertlestak
Copy link
Copy Markdown
Author

@SgtCoDFish hope you had a happy and restful holiday with the growing family 😀

Picking this back up, I made the requested changes and all tests are passing 🎉

I've tested my version in one of our environments which is currently facing the issue (currently on v1.19.1) and it worked as expected - default config continued to fail (as expected) but after increasing the size limit values in the config, the cert was properly issued and sync'ed into k8s.

Just joined the #cert-manager-dev slack channel, thanks for the guidance and assistance, looking forward to continuing to contribute to this great project!

Signed-off-by: robert lestak <robert.lestak@umusic.com>
Copy link
Copy Markdown
Contributor

@ThatsMrTalbot ThatsMrTalbot left a comment

Choose a reason for hiding this comment

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

Hiya @robertlestak, I've only got a couple of comments, on the whole this looks good

- Add sync.RWMutex to protect concurrent access to globalSizeLimits
- Use Lock/Unlock in SetGlobalSizeLimits for write operations
- Use RLock/RUnlock in GetGlobalSizeLimits for read operations
- Replace all direct globalSizeLimits accesses with GetGlobalSizeLimits() calls

Addresses review feedback from ThatsMrTalbot on PR #7642

Signed-off-by: robert lestak <robert.lestak@umusic.com>
@ThatsMrTalbot
Copy link
Copy Markdown
Contributor

Thanks for making those changes!
/lgtm
/approve

@cert-manager-prow
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ThatsMrTalbot

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

The pull request process is described 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

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/acme/dns01 Indicates a PR modifies ACME DNS01 provider code area/acme/http01 Indicates a PR modifies ACME HTTP01 provider code 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 area/monitoring Indicates a PR or issue relates to monitoring area/testing Issues relating to testing area/vault Indicates a PR directly modifies the Vault Issuer code dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/bug Categorizes issue or PR as related to a bug. kind/design Categorizes issue or PR as related to design. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. ok-to-test release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants