Skip to content

Switch httpcore2 from certifi to truststore for default SSL verification#1002

Merged
Kludex merged 4 commits into
mainfrom
switch-httpcore2-to-truststore
Jun 1, 2026
Merged

Switch httpcore2 from certifi to truststore for default SSL verification#1002
Kludex merged 4 commits into
mainfrom
switch-httpcore2-to-truststore

Conversation

@Kludex

@Kludex Kludex commented Jun 1, 2026

Copy link
Copy Markdown
Member

#209 switched httpx2 to truststore but left httpcore2 declaring certifi directly and loading certifi.where() in default_ssl_context(). Since httpx2 always builds its own truststore context and passes it down, certifi was only ever exercised when httpcore2 is used directly with ssl_context=None - but it was still installed and imported regardless.

This mirrors #209 at the httpcore2 layer. certifi now survives only as a transitive test dependency of requests, no longer pulled in by either package.

mypy, ruff, and the full httpcore2 test suite (223 tests) pass.

AI Disclaimer

This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.

…ication

Mirrors #209, which only switched httpx2. httpcore2 still declared `certifi` directly and loaded it in `default_ssl_context()`, so it was installed and imported even though httpx2 always passes its own truststore context down. `certifi` now remains only as a transitive test dependency of `requests`.
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

@codspeed-hq

codspeed-hq Bot commented Jun 1, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 15 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing switch-httpcore2-to-truststore (7930a59) with main (4fe6b77)

Open in CodSpeed

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 635c68bdbb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/httpcore2/httpcore2/_ssl.py
Bare `truststore.SSLContext` ignores the OpenSSL CA env overrides, so direct httpcore2 users relying on them for a corporate/private CA would lose verification. Mirror the `httpx2.create_ssl_context()` fallback.
Match httpx2's `# pragma: no cover` precedent for the env-override paths instead of testing them.
@Kludex Kludex enabled auto-merge (squash) June 1, 2026 10:33
@Kludex Kludex merged commit debebf1 into main Jun 1, 2026
14 checks passed
@Kludex Kludex deleted the switch-httpcore2-to-truststore branch June 1, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant