aio-libs / aio-libs/aiohttp

[TODO] Use `truststore` in place of `ssl` by default

Đang mở
#11,705 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement Hacktoberfest need pull request
Ngôn ngữ chính
Python
Star
16.5k
Fork
2.4k
Merge trung bình
17 giờ 22 phút
Pull request đã merge (30 ngày)
212

Mô tả

### Is your feature request related to a problem?

I mentioned this [once](https://github.com/aio-libs/aiohttp/issues/8430#issuecomment-2139581921) or [twice](https://github.com/aio-libs/aiohttp/issues/9296#issuecomment-2376954905) in the past. Now, I'm filing a tracking issue with action items.

People often face the problem of TLS certificate verification failing in the Python land while other tools in the same OS/runtime work. This is because Python's stdlib `ssl` is not set up to consult system trust stores.

The `truststore` library implements this with its drop-in replacement `SSLContext` and OS-specific API integrations. pip 24.2+ uses it by default and we should too.

This will improve the UX for our HTTP client. Though, the end-users can still use either stdlib `ssl`, or `truststore`-produce when passing an explicit context object.

### Describe the solution you'd like

Relying on system-managed TLS trust stores when making HTTPS requests.

Action items:
* [ ] locate all places constructing `ssl.SSLContext` objects (may be created via `ssl.create_default_context()`)
* [ ] replace those with `truststore.SSLContext`
* [ ] in runtime, prefer `truststore` which should be shielded on import with a fallback to just stdlib `ssl`
* [ ] `truststore` should probably be a mandatory runtime dependency in packaging core metadata; although, maybe we need to follow pip's example and make it optional first (via extras or manual install) and then add it unconditionally later
* [ ] document the priority and the compatibility considerations

### Describe alternatives you've considered

N/A

### Related component

Client

### Additional context

* https://truststore.rtfd.io
* https://pypi.org/p/truststore

### Code of Conduct

- [x] I agree to follow the aio-libs Code of Conduct

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.