-
-
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
Session.verify=False ignored when REQUESTS_CA_BUNDLE environment variable is set #3829
Comments
Thanks for raising this issue! This is a related issue to #2018: specifically, we prefer the environment to the Given that we fail-closed here (that is, it's not possible to use this arrangement to force us not to verify when we should), this isn't a security vulnerability, so there is no way we can justify bringing it forward to before v3. |
OK, thanks for the quick response. Is 3.0.0 coming some time soon or is it just a plan for now? |
"soon" is a bit strong. However, there's a branch that code can be committed to, and there is active work being done on urllib3 v2, which once done will be the catalyst for us to actually ship requests v3. |
For whoever else is struggling with this problem, I created a wrapper class as workaround: class WrappedSession(requests.Session):
"""A wrapper for requests.Session to override 'verify' property, ignoring REQUESTS_CA_BUNDLE environment variable.
This is a workaround for https://github.com/kennethreitz/requests/issues/3829 (will be fixed in requests 3.0.0)
"""
def merge_environment_settings(self, url, proxies, stream, verify, *args, **kwargs):
if self.verify is False:
verify = False
return super(WrappedSession, self).merge_environment_settings(url, proxies, stream, verify, *args, **kwargs) |
This issue hit me today. I had to debug a good amount of code to track it down. Where are we now relative to when it was identified back in January? |
No change. |
as my test in win10 python 3.6.4, requests (2.18.3) (not until v3 ??) urllib3 (1.22) the
worked, and will prompt a warning message:
to disable the warning message, just:
|
The 'fail close, so no security issue' argument is only correct if the verify is set to If the verify is set to a subset of the global CAs for access to some systems (as a poor mans form of certificate pinning) this fails open. So when used in a library that allows specifiying certificate authorities to allow for e.g. authentication backends that use sessions to allow easier cookie flows, the globally set environments (e.g. to allow access to internet sites in other parts of the program) invalidates this unless the library takes extra precautions. For example: |
Due to open bug for requests python package: psf/requests#3829 Remove the "REQUESTS_CA_BUNDLE" env param when ssl verify is false. Change-Id: Ifc47937bdc5839b08af93851f012a1a67075c453
It would be nice if requests could at least throw a warning about this. I just spend 6 hours trying to figure out what is going on, then found out that |
It's funny that this "fix" is delayed to v3 because it's considered "breaking change", yet a huge number of people keep burning hours pinning down this behavior. |
We spent 3 hours on this, third party library was set env |
When session.verify=False, session.trust_env=True and REQUESTS_CA_BUNDLE or CURL_CA_BUNDLE is defined as environment variables then, notify user that requests will use environment variables rather than silently failing. partially fixes: psf#3829 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
When session.verify=False, session.trust_env=True and REQUESTS_CA_BUNDLE or CURL_CA_BUNDLE is defined as environment variables then, notify user that requests will use environment variables rather than silently failing. partially fixes: psf#3829 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Since this is fixed in requests 3.* version, I added a mechanism to warn the user via #5816. Please provide feedback on the PR. |
When session.verify=False, session.trust_env=True and REQUESTS_CA_BUNDLE or CURL_CA_BUNDLE is defined as environment variables then, notify user that requests will use environment variables rather than silently failing. partially fixes: psf#3829 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Due to psf/requests#3829, the `verify` flag has no effect when the `REQUESTS_CA_BUNDLE` environment variable is set.
Due to psf/requests#3829, the `verify` flag has no effect on Sssions when the `REQUESTS_CA_BUNDLE` env variable is set.
Due to psf/requests#3829, the `verify` flag has no effect on Sssions when the `REQUESTS_CA_BUNDLE` env variable is set.
Due to this issue: psf/requests#3829 the confluence_disable_ssl_validation setting does not work in all cases. As described in the requests issue, passing the verify variable into the method call does work. Signed-off-by: Ben Gale <bengale2007@googlemail.com>
When session.verify=False, session.trust_env=True and REQUESTS_CA_BUNDLE or CURL_CA_BUNDLE is defined as environment variables then, notify user that requests will use environment variables rather than silently failing. partially fixes: psf#3829 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
if the env REQUESTS_CA_BUNDLE is set the requests.Session() ignores the verify parameter. Therefore the verify parameter is moved directly into the function call of request. Workaround for psf/requests#3829 Change-Id: I66dc7c4d90e5bd5e3d1b331cf1728f27dece6dd4
* Update sushy from branch 'master' to 98c899997f4f7b7aaccf911c41655aad6548fe6c - workaround: requests verify handling if env is set if the env REQUESTS_CA_BUNDLE is set the requests.Session() ignores the verify parameter. Therefore the verify parameter is moved directly into the function call of request. Workaround for psf/requests#3829 Change-Id: I66dc7c4d90e5bd5e3d1b331cf1728f27dece6dd4
if the env REQUESTS_CA_BUNDLE is set the requests.Session() ignores the verify parameter. Therefore the verify parameter is moved directly into the function call of request. Workaround for psf/requests#3829 Change-Id: I66dc7c4d90e5bd5e3d1b331cf1728f27dece6dd4 (cherry picked from commit 98c8999)
if the env REQUESTS_CA_BUNDLE is set the requests.Session() ignores the verify parameter. Therefore the verify parameter is moved directly into the function call of request. Workaround for psf/requests#3829 Change-Id: I66dc7c4d90e5bd5e3d1b331cf1728f27dece6dd4
Hello, Is this documented ? Official documentation did not mention this behaviour. I lost 2 hours.. |
Due to bug psf/requests#3829, setting 'verify' on session doesn't work if REQUESTS_CA_BUNDLE is set on environment. The bundle defined via REQUESTS_CA_BUNDLE will take precedence and the custom bundle provided via 'verify' is ignored. Let's now set 'verify' for each request. This can be revetrted when the bug is fixed, likely in python-requests-v3.
One would expect that when the caller explicitly asks to make unverified requests, then the
REQUESTS_CA_BUNDLE
environment variable doesn't affect it. The reality is different, however.The text was updated successfully, but these errors were encountered: