Skip to content

fix(vault): support cross-signed intermediate CAs - #8786

Closed
Kouzi99 wants to merge 1 commit into
cert-manager:masterfrom
Kouzi99:fix/vault-cross-signed-intermediate-ca
Closed

Kouzi99 wants to merge 1 commit into
cert-manager:masterfrom
Kouzi99:fix/vault-cross-signed-intermediate-ca

Conversation

@Kouzi99

@Kouzi99 Kouzi99 commented May 14, 2026

Copy link
Copy Markdown

Pull Request Motivation

When Vault issues a cross-signed intermediate CA (an intermediate certificate
signed by multiple root CAs simultaneously), cert-manager failed with
certificate chain is malformed or broken. This is because the chain parser
requires a single linear chain, but cross-signing creates a branching graph.

Cross-signing is the recommended approach for root CA rotation in Vault PKI:
https://developer.hashicorp.com/vault/docs/secrets/pki/rotation-primitives

Fix: fall back to using raw Vault certificate data when the chain cannot be
linearized, so cross-signed intermediates pass through correctly.

Fixes #7645

Kind

/kind bug

Release Note

Fix cert-manager failing with cross-signed intermediate CAs issued by Vault PKI

When Vault issues a cross-signed intermediate CA signed by multiple root
CAs, cert-manager failed with 'certificate chain is malformed or broken'.
Fall back to using raw Vault data when the chain cannot be linearized.

Fixes cert-manager#7645

Signed-off-by: kouzi99 <[email protected]>
@cert-manager-prow

Copy link
Copy Markdown
Contributor

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

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 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. 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 May 14, 2026
@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 joshvanl 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 the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 14, 2026
@cert-manager-prow

Copy link
Copy Markdown
Contributor

Hi @Kouzi99. 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/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 14, 2026
@joemiller

Copy link
Copy Markdown

also running into this. cross-signing and using manual_chain is a recommended way in vault docs to handle rotation. would be great to get this into cert-manager

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds Vault support for certificate bundles containing cross-signed intermediate CAs.

Changes:

  • Falls back to raw Vault certificate data for non-linear chains.
  • Adds cross-signed certificate fixtures and regression coverage.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
internal/vault/vault.go Adds raw certificate-chain fallback.
internal/vault/vault_test.go Tests Vault cross-signed bundles.
pkg/util/pki/parse_certificate_chain_test.go Documents parser behavior for branching chains.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +471 to +473
if len(cert) == 0 {
t.Error("expected non-empty cert chain")
}
Comment thread internal/vault/vault.go
Comment on lines 871 to +875
if err != nil {
return nil, nil, fmt.Errorf("failed to parse certificate chain from vault: %w", err)
// Vault may return a cross-signed intermediate CA signed by multiple root CAs.
// The parser requires a single linear chain and fails in that case.
// Fall back to using the raw Vault data directly.
chainPEM := strings.Join(append([]string{vbundle.Certificate}, vbundle.CAChain...), "\n")

@wallrj wallrj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @Kouzi99 for this PR and for the clear write-up — the motivation is spot on: cross-signing is exactly what Vault recommends for root rotation, and cert-manager should handle it.

After looking closely, we've decided to concentrate on fixing the root cause rather than working around it here. The rejection comes from ParseSingleCertificateChain's single-linear-chain model, which affects the Venafi and CA issuers as well as Vault. A raw-response fallback in the Vault issuer would also bypass the parser's validation and size limits, so a genuinely malformed chain from Vault would be returned as a successful issuance.

I've opened #9150, which teaches the shared parser to accept cross-signed bundles by deterministically selecting one path — that fixes all issuers with no Vault-specific changes, and keeps broken chains rejected. I'm going to close this PR in favour of that one. Reviews and testing on #9150 would be very welcome, particularly against a real Vault mount with a cross-signed intermediate.

Thanks again for pushing this forward!

with claude fable-5

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

Labels

dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. kind/bug Categorizes issue or PR as related to a bug. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support cross-signed intermediate CAs issued with Vault

4 participants