Skip to content

Trust ca_cert_data in the websocket client - #2794

Open
Yohan-Senadheera wants to merge 1 commit into
kubernetes-client:masterfrom
Yohan-Senadheera:ws-ca-cert-data
Open

Yohan-Senadheera wants to merge 1 commit into
kubernetes-client:masterfrom
Yohan-Senadheera:ws-ca-cert-data

Conversation

@Yohan-Senadheera

Copy link
Copy Markdown

What type of PR is this?

/kind bug

What this PR does / why we need it:

Configuration.ca_cert_data works for REST calls, because it is passed to urllib3. The websocket client ignores it: create_websocket only reads ssl_ca_cert and otherwise trusts the certifi bundle. So with the cluster CA given only as data, list_namespaced_pod works but exec, attach and port-forward fail with CERTIFICATE_VERIFY_FAILED.

websocket-client has no option for CA data, so when ca_cert_data is set this builds an SSL context with it and passes it in. The context also loads ssl_ca_cert, the client certificate and assert_hostname, since websocket-client skips those options when a context is given.

Tested against a kind cluster with only ca_cert_data set (no CA file):

  • master: the REST call works, exec fails with CERTIFICATE_VERIFY_FAILED
  • this branch: exec returns the command output

The new unit tests fail on master and pass here. All kubernetes/stream tests pass.

Which issue(s) this PR fixes:

None filed.

Does this PR introduce a user-facing change?

Exec, attach and port-forward now trust the CA given in Configuration.ca_cert_data.

Configuration.ca_cert_data is passed to urllib3 for REST calls, but
create_websocket only used ssl_ca_cert and fell back to the certifi
bundle. Exec, attach and port-forward then failed certificate
verification when the cluster CA was given only as data.

Build an SSL context with the CA data (and ssl_ca_cert, the client
certificate and assert_hostname) and pass it to websocket-client.

Signed-off-by: Yohan Senadheera <yohansenadheera@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 18, 2026 02:31
@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. labels Nov 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@kubernetes-prow
kubernetes-prow Bot requested a review from roycaihw November 18, 2026 02:31
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Yohan-Senadheera
Once this PR has been reviewed and has the lgtm label, please assign roycaihw 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

@kubernetes-prow
kubernetes-prow Bot requested a review from yliaog November 18, 2026 02:31
@kubernetes-prow kubernetes-prow Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

2 participants