-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
requests should ignore REQUESTS_CA_BUNDLE when session.verify is False #5921
Comments
Hey @brmzkw, thanks for the detailed rundown! I agree this behavior seems wrong and I'd be inclined to treat it as a bug. I've got some general feedback on the PR, but before we start that, I'd like to make sure we map this out completely.
Once we have that, it'll help us inform the eventual change. In general we try to adhere to a precedence order of method kwargs > Request > Session > Environment. We'll want to make sure we're maintaining that to the best of our ability. |
Hello and thanks for your quick review! The tests below should cover what you asked. They have been run with and without the patch from my pull request, and all the results are similar in both cases. ✅ REQUESTS_CA_BUNDLE is empty, using prepped request: exception is raised
I don't understand why this exception. REQUESTS_CA_BUNDLE isn't used. This is likely a problem, but not related to this issue. ✅ REQUESTS_CA_BUNDLE is invalid, using prepped request, set verify=False in session.send(): no exception
✅ REQUESTS_CA_BUNDLE is invalid, using prepped request, set session.verify = False: no exception
|
Thanks for checking on those, @brmzkw! I agree the invalid bundle for Unfortunately, I started leaving feedback on the PR and realized I'd oversimplified the problem yesterday. Fixing this introduces some breakages into When we do come around to fixing this, I'll try to layout what things should look like with an invalid REQUESTS_CA_BUNDLE or CURL_CA_BUNDLE: Requests 2.26.0 (Wrong):
#5922 PR (Better):
Desired Behavior (method kwargs > Session):
This gets a bit more nuanced when we look at So to summarize, I'll mark this as a bug but it may be a considerable amount of time before it can be addressed in a new major version. Thanks for the report though, we do truly appreciate it! |
It looks like this was actually identified several years ago in #3829 but has been sitting since with the same conclusion. I think we've got some more useful information here that wasn't part of the initial ticket. We'll leave this here as a bread crumb on the initial ticket but I'm going to resolve this in favor of the original to consolidate tracking. Thanks again, @brmzkw! |
The argument
session.verify
set to False is ignored when the environment variableREQUESTS_CA_BUNDLE
is set.Reproduction Steps
✅ empty
REQUESTS_CA_BUNDLE
andsession.verify = True
: exception is raised✅ empty
REQUESTS_CA_BUNDLE
andsession.verify = False
: no exception raised✅
REQUESTS_CA_BUNDLE
is invalid, and noverify
is given torequests.get
(defaults toTrue
): exception is raised becauseREQUESTS_CA_BUNDLE
is invalid✅
REQUESTS_CA_BUNDLE
is invalid andverify=False
is given torequests.get
: no exception raised✅
REQUESTS_CA_BUNDLE
is invalid andsession.verify = True
: exception is raised❌
REQUESTS_CA_BUNDLE
is invalid andsession.verify = False
: exception is raisedThe problem comes from
requests/requests/sessions.py
Line 717 in b0e025a
self.verify
.The text was updated successfully, but these errors were encountered: