Session adapter doesn't update https connections cert data
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 54.3k
- Forks
- 10.4k
- Avg merge
- 16h 43m
- Merged PRs (30d)
- 3
Description
Under a session, the first https request sets the HTTPSConnectionPool certs data.
If in a subsequent request, we change the certs data (eg: Set verify to True), the adaptor will update the ConnectionPool attributes, however each connection in the pool will still contain the old certs data, thus when requesting a connection from the pool, its info will differ from what we would expect.
Expected Result
The used connection should have updated certs data
Actual Result
The used connection have "old" certs data.
Reproduction Steps
These tests where performed against a server with a self-signed CA.
In [1]: from requests import Session
In [2]: url = "https://somepage"
In [3]: auth = ("admin", "admin123")
In [4]: s = Session()
In [5]: s.get(url, auth=auth, verify=False)
Out[5]: <Response [200]>
# This should fail, but doesnt
In [6]: s.get(url, auth=auth, verify=True)
Out[6]: <Response [200]>
# Create a new session
In [7]: Session().get(url, auth=auth, verify=True)
# Raises certificate verify failed
I'm aware ConnectionPool is in urllib realm, but since it's the adaptor who is updating the pool data, perhaps it should also handle this scenario?
System Information
{
"chardet": {
"version": "3.0.4"
},
"cryptography": {
"version": "1.7.2"
},
"idna": {
"version": "2.6"
},
"implementation": {
"name": "CPython",
"version": "2.7.12"
},
"platform": {
"release": "4.4.0-59-generic",
"system": "Linux"
},
"pyOpenSSL": {
"openssl_version": "1000207f",
"version": "16.0.0"
},
"requests": {
"version": "2.18.4"
},
"system_ssl": {
"version": "1000207f"
},
"urllib3": {
"version": "1.22"
},
"using_pyopenssl": true
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two sequential HTTPS requests described in the issue, changing verify from False to True on the same Session. Trace the Session adapter's connection-pool updates and the pooled connections' certificate data; done means the reused connection reflects the updated certificate settings and the reported behavior is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100