Skip to content
Merged
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
11 changes: 7 additions & 4 deletions src/httpcore2/httpcore2/_ssl.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import os
import ssl

import certifi
import truststore


def default_ssl_context() -> ssl.SSLContext:
context = ssl.create_default_context()
context.load_verify_locations(certifi.where())
return context
if cafile := os.environ.get("SSL_CERT_FILE"): # pragma: no cover
return ssl.create_default_context(cafile=cafile)
if capath := os.environ.get("SSL_CERT_DIR"): # pragma: no cover
return ssl.create_default_context(capath=capath)
return truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
Comment thread
Kludex marked this conversation as resolved.
2 changes: 1 addition & 1 deletion src/httpcore2/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ classifiers = [
"Programming Language :: Python :: 3.14",
"Topic :: Internet :: WWW/HTTP",
]
dependencies = ["certifi", "h11>=0.16"]
dependencies = ["truststore>=0.10", "h11>=0.16"]

[project.optional-dependencies]
http2 = ["h2>=3,<5"]
Expand Down
4 changes: 2 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading