fix: remove truststore.SSLContext injection to fix InsecureRequestWarning#613
Open
fix: remove truststore.SSLContext injection to fix InsecureRequestWarning#613
Conversation
…ning The SslBypassRequestsAdapter was injecting truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT) into the urllib3 pool manager. This custom SSLContext has a known incompatibility with the requests/urllib3 adapter pattern on macOS (truststore#167), causing urllib3's is_verified tracking to incorrectly report connections as unverified, triggering InsecureRequestWarning. SSL verification is already properly handled through: - The verify parameter (certifi CA bundle) passed by the conjure client - urllib3's standard cert_verify flow setting cert_reqs=CERT_REQUIRED - urllib3 creating its own properly-tracked ssl context For corporate networks needing system trust store access, users can set trust_store_path or call truststore.inject_into_ssl() in their application. Co-Authored-By: Leo Galindo-Frias <leogalindofrias@gmail.com>
Contributor
Original prompt from Leo |
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Greptile Overview
|
| Filename | Overview |
|---|---|
| nominal/core/_utils/networking.py | Removes truststore.SSLContext injection from SslBypassRequestsAdapter.init_poolmanager() to fix InsecureRequestWarning on macOS. SSL verification continues to work through the standard requests/urllib3 verify parameter flow. The truststore dependency remains in pyproject.toml as unused. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes the
truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT)injection fromSslBypassRequestsAdapter.init_poolmanager()to fixInsecureRequestWarningreported by users streaming via the Python client on macOS.SSL verification continues to work through the standard requests/urllib3 flow: the
verifyparameter (certifi CA bundle or customtrust_store_path) is already passed on every request by the conjure client.Context
Users reported:
The
truststore.SSLContextwrapper stores an internal_ctxand delegateswrap_socketto it. When urllib3 sets/readsverify_modeon the wrapper to track verification status (is_verified), this can interact poorly with the wrapper's internal context on certain platforms. Thetruststorelibrary has a known open issue with this adapter pattern on macOS: sethmlarson/truststore#167What changed
truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT)injection fromSslBypassRequestsAdapter.init_poolmanager()import sslandimport truststoreImportant review considerations
Corporate network regression risk: The truststore SSLContext was added in feat: allow using truststore for ssl bypass #472 specifically to support corporate networks with custom CAs in their system trust store. This change means those users would need to either pass a
trust_store_pathexplicitly or calltruststore.inject_into_ssl()in their application. Reviewers should assess whether this trade-off is acceptable.Root cause was not reproduced: The warning could not be reproduced on Linux (only reported on macOS + Python 3.13). The fix is based on code analysis + the upstream truststore#167 issue, not a confirmed reproduction.
truststoredependency is now unused but still listed inpyproject.toml— could be cleaned up in a follow-up.SslBypassRequestsAdapterclass name is now misleading since it no longer does anything SSL-related (just keep-alive). Renaming deferred to avoid scope creep.Link to Devin run | Requested by: @Leundai