fix: add disable_strict_ssl_verification to sync client#2611
Conversation
|
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sajjadghf The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds an opt-in configuration flag to relax strict X.509 verification in the Kubernetes Python client by supplying a custom ssl.SSLContext to urllib3, and includes patch files intended to capture/apply these changes.
Changes:
- Introduces
disable_strict_ssl_verificationtoConfiguration. - Builds an
SSLContextand clearsVERIFY_X509_STRICTwhen the flag is enabled, passing it viassl_contextto urllib3 managers. - Adds two
.difffiles underscripts/representing the patch.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| scripts/rest_client_disable_ssl_strict_verification_patch.diff | Adds a patch file intended to modify REST client SSL handling. |
| scripts/client_configuration_disable_ssl_strict_verification_patch.diff | Adds a patch file intended to add the new configuration flag. |
| kubernetes/client/rest.py | Switches urllib3 SSL configuration to use either explicit cert params or a custom SSLContext with relaxed X509 strict checks. |
| kubernetes/client/configuration.py | Adds disable_strict_ssl_verification configuration attribute and its inline documentation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c0c7ac6 to
35d66e5
Compare
35d66e5 to
f3b6a1f
Compare
What type of PR is this?
/kind bug
/kind feature
What this PR does / why we need it:
Since Python 3.13,
ssl.VERIFY_X509_STRICTis enforced by default viaSSLContext.verify_flags. This causes TLS handshakes to fail when theserver's certificate is missing extensions that RFC 5280 mandates in
strict mode (e.g.
X509v3 Subject Key Identifier,X509v3 Authority Key Identifier,X509v3 Subject Alternative Name).Many real-world Kubernetes clusters (especially self-signed or
internally issued PKI) issue certificates without these extensions.
The async client (
kubernetes.aio.client) already exposes adisable_strict_ssl_verificationflag on itsConfigurationclass,and the matching
RESTClientObjectstripsssl.VERIFY_X509_STRICTfrom the
SSLContext.verify_flagswhen the flag is set. The syncclient (
kubernetes.client) was missing this support entirely.This PR:
disable_strict_ssl_verification = Falsetokubernetes.client.configuration.Configurationwith the samedocstring as the async counterpart.
kubernetes.client.rest.RESTClientObject.__init__tobuild the SSL keyword arguments into a single
ssl_pool_kwargsdict.When
disable_strict_ssl_verificationisTrue, a fully-configuredssl.SSLContext(withVERIFY_X509_STRICTremoved) is created andpassed directly to
urllib3.PoolManager/urllib3.ProxyManager,avoiding the deprecation of mixing
ssl_contextwith individual SSLparameters in urllib3 ≥ 2.x.
scripts/to document the changes forfuture client regeneration cycles.
Which issue(s) this PR fixes:
Fixes #2602
Special notes for your reviewer:
RESTClientObjectusesurllib3(notaiohttp), so theSSL context is built with
ssl.create_default_context()and passedvia the
ssl_contextkwarg to urllib3's pool managers, rather thanvia
aiohttp.TCPConnectoras in the async client.ssl_contextand the individual cert parameters(
cert_reqs,ca_certs,cert_file,key_file) simultaneously tourllib3 ≥ 2.x triggers a
DeprecationWarning. The refactored codeuses mutually exclusive dict unpacking (
ssl_pool_kwargs) to avoidthis.
disable_strict_ssl_verification=Trueandverify_ssl=Falsethe code mirrors the async client:
check_hostnameis disabled andverify_modeis set tossl.CERT_NONE.Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: