Skip to content
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

Always use value of session.verify when set, fixes #5921 #5922

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requests/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ def merge_environment_settings(self, url, proxies, stream, verify, cert):

# Look for requests environment configuration and be compatible
# with cURL.
if verify is True or verify is None:
if (verify is True or verify is None) and (self.verify is True or self.verify is None):
verify = (os.environ.get('REQUESTS_CA_BUNDLE') or
os.environ.get('CURL_CA_BUNDLE'))

Expand Down
12 changes: 12 additions & 0 deletions tests/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,18 @@ def test_invalid_ca_certificate_path(self, httpbin_secure):
requests.get(httpbin_secure(), verify=INVALID_PATH)
assert str(e.value) == 'Could not find a suitable TLS CA certificate bundle, invalid path: {}'.format(INVALID_PATH)

def test_invalid_ca_certificate_path_w_verif_false(self, httpbin_secure):
INVALID_PATH = '/garbage'
with override_environ(requests_ca_bundle=INVALID_PATH):
requests.get(httpbin_secure(), verify=False)

def test_invalid_ca_certificate_path_w_session_verif_false(self, httpbin_secure):
INVALID_PATH = '/garbage'
with override_environ(requests_ca_bundle=INVALID_PATH):
session = requests.Session()
session.verify = False
session.get(httpbin_secure())

def test_invalid_ssl_certificate_files(self, httpbin_secure):
INVALID_PATH = '/garbage'
with pytest.raises(IOError) as e:
Expand Down