Skip to content

Allow partial chain IdP CA in OIDC refresh - #2800

Merged
kubernetes-prow[bot] merged 3 commits into
kubernetes-client:masterfrom
chala2001:idp-partial-chain
Nov 30, 2026
Merged

kubernetes-prow[bot] merged 3 commits into
kubernetes-client:masterfrom
chala2001:idp-partial-chain

Conversation

@chala2001

@chala2001 chala2001 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:

When the OIDC IdP CA in the kubeconfig is a leaf or intermediate cert, kubectl accepts it but the Python client fails with "self-signed certificate in certificate chain". On Python 3.12 and older OpenSSL needs a self-signed root unless VERIFY_X509_PARTIAL_CHAIN is set. Python 3.13 sets it by default.

_refresh_oidc now does the discovery GET with the same requests session as the token refresh, and mounts a small adapter that sets the flag when an IdP CA is given. Only kube_config.py changes, no generated code.

Which issue(s) this PR fixes:

Fixes #2415

Special notes for your reviewer:

Tested end to end on 3.12 with a local IdP and a root, intermediate, leaf chain. Leaf or intermediate as the CA failed before and works now. An unrelated CA and a wrong hostname still fail. Also checked on 3.13.

With no IdP CA set, discovery still skips verification like before. The asyncio client is not changed here.

Does this PR introduce a user-facing change?

OIDC token refresh now accepts an IdP CA that is a leaf or intermediate certificate, like kubectl.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@kubernetes-prow kubernetes-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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 22, 2026
@kubernetes-prow
kubernetes-prow Bot requested review from roycaihw and yliaog November 22, 2026 07:25
@yliaog

yliaog commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

@chala2001

could you make the change in the upstream openapi-generator? so we don't need to carry a patch in this repo?

@roycaihw roycaihw 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.

Only the IdP calls need this. _refresh_oidc already uses a requests session for the token refresh; can the discovery GET go through the same session with your adapter? Then we don't need the Configuration field or the generated-code patch, and nothing to upstream.

@chala2001

Copy link
Copy Markdown
Contributor Author

@roycaihw thanks, good idea. Discovery now uses the same requests session with the adapter, so the Configuration field and the generated code patch are gone. Tested again on 3.12 and 3.13 with leaf, intermediate and root CA.

@yliaog with this change nothing needs to go upstream.

@yliaog

yliaog commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Minor / non-blocking nit

Wrapping OAuth2Session(...) in a with block would close its connection pool after _refresh_oidc() returns (pre-existing code didn't close it either, so not a regression).

@chala2001

Copy link
Copy Markdown
Contributor Author

@yliaog done in cc7c124, the session is now in a with block. Thanks.

@yliaog

yliaog commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

thanks for the PR

/lgtm
/approve

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

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chala2001, yliaog

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

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 30, 2026
@kubernetes-prow
kubernetes-prow Bot merged commit a5f5a39 into kubernetes-client:master Nov 30, 2026
10 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. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

IDP certificate issue

3 participants