Skip to content

Preserve TLS policy errors during custom CA validation - #1964

Merged
kubernetes-prow[bot] merged 2 commits into
masterfrom
bolian/custom-ca-validation
Oct 16, 2026
Merged

kubernetes-prow[bot] merged 2 commits into
masterfrom
bolian/custom-ca-validation

Conversation

@tg123

@tg123 tg123 commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Custom CA validation now rebuilds the certificate chain only when RemoteCertificateChainErrors is the sole TLS policy error. If a hostname mismatch or missing-certificate error is also present, the callback returns false rather than allowing a successful chain rebuild to override those errors.

The existing chain-building logic is unchanged. HTTPS and WebSocket connections use the same callback.

Adds a regression test confirming that a certificate signed by a configured custom CA is accepted for chain errors alone and rejected when a hostname mismatch is also reported.

Updates the existing mutual-TLS authentication test to use the certificate fixture's DNS name as TlsServerName. The mock server listens on a loopback address that does not match the fixture's name; certificate verification remains enabled.

Validation

Ran the authentication and certificate-validation tests on .NET 10 in WSL: 21 passed, 0 failed.

dotnet test tests/KubernetesClient.Tests/KubernetesClient.Tests.csproj --framework net10.0 --filter "FullyQualifiedName~AuthTests|FullyQualifiedName~CertificateValidationTests" --verbosity minimal

Copilot AI balanced review requested due to automatic review settings October 16, 2026 08:04
@kubernetes-prow kubernetes-prow Bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 16, 2026

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.

🟢 Approval recommended

The focused guard preserves other TLS failures, with regression coverage and no unresolved findings.

0 open findings

What changed in this PR

Prevents custom CA validation from overriding unrelated TLS policy errors in the Kubernetes client.

Changes:

  • Rebuilds the certificate chain only when chain errors are the sole TLS failure.
  • Adds regression coverage for accepting chain-only errors and rejecting combined hostname and chain errors.
File Description
tests/​KubernetesClient.Tests/​CertificateValidationTests.cs Tests custom CA acceptance and hostname mismatch rejection.
src/​KubernetesClient/​Kubernetes.ConfigInit.cs Restricts custom CA validation to chain-only errors.

🧠 Review effort: Balanced


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

@brendandburns

Copy link
Copy Markdown
Contributor

Looks reasonable to me but tests are failing.

Copilot AI balanced review requested due to automatic review settings October 16, 2026 22:31

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.

🟢 Approval recommended

The focused change preserves chain-building behavior, adds relevant regression coverage, and has no identified blocking issues.

No open issues 🎉

Review effort: Balanced

@brendandburns

Copy link
Copy Markdown
Contributor

/lgtm
/approve

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 16, 2026
@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns, tg123

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:
  • OWNERS [brendandburns,tg123]

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

@kubernetes-prow
kubernetes-prow Bot merged commit 1c727cc into master Oct 16, 2026
17 checks passed
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

3 participants