Registry / auth-security / truststore

truststore

JSON →
library0.10.4pypypi✓ verified 26d ago

Truststore is a Python library that enables certificate verification using native system trust stores on macOS, Windows, and Linux, providing a more secure and consistent approach to SSL/TLS. It is currently at version 0.10.4 and maintains an active release cadence with frequent bug fixes and platform improvements.

pip install truststore
INSTALL
IMPORT
SIG · TRUSTSTORE
T
truststore
auth-securitypythonv0.10.4
Install
1.5s avg
Import
47ms
Disk
15MB
Pass rate
8/ 10
Env Coverage8 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.10.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 1.5s
py 3.11
✓ —
✓ 1.6s
py 3.12
✓ —
✓ 1.5s
py 3.13
✓ —
✓ 1.5s
py 3.9
✕ build_error
✕ build_error
15MB installed
● package 15MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

inject_into_ssl
import truststore; truststore.inject_into_ssl()
extract_from_ssl
import truststore; truststore.extract_from_ssl()
Used to revert the global patch applied by inject_into_ssl().
SSLContext
from truststore import SSLContext
For explicit use, less common than global injection for most applications.

The most common way to use truststore is by calling `truststore.inject_into_ssl()` early in your application's execution. This globally patches `ssl.SSLContext`, causing libraries like `requests` and `httpx` to automatically use the system's trust store for certificate verification. This example demonstrates making a simple request with `requests` after injection.

import truststore import requests # Call inject_into_ssl() as early as possible in your application's lifecycle. # This patches the default SSLContext used by many libraries (e.g., requests, httpx). truststore.inject_into_ssl() try: # requests will now use the system trust store for verification response = requests.get('https://www.google.com', timeout=5) response.raise_for_status() print(f"Successfully connected to Google: {response.status_code}") except requests.exceptions.RequestException as e: print(f"Error connecting: {e}")
Debug
Known issues
gotchaThe `truststore.inject_into_ssl()` function must be called as early as possible in your application's lifecycle, before any `ssl.SSLContext` objects are created by other libraries (e.g., `requests`, `httpx`, `urllib3`). Contexts created before injection will not use the system trust store.
fix
Ensure `truststore.inject_into_ssl()` is one of the first lines of executable code in your main script or entry point.
affects: All versions
breakingVersions prior to 0.10.4 had a thread-safety issue when configuring the internal `ssl.SSLContext` object, potentially leading to incorrect behavior or crashes in multi-threaded applications.
fix
Upgrade to truststore 0.10.4 or higher to resolve the thread-safety bug. If unable to upgrade, avoid using truststore in multi-threaded contexts where `SSLContext` objects are frequently configured.
affects: <0.10.4
gotchaTruststore requires Python 3.10 or newer. Attempting to install or use it on older Python versions will result in an `ImportError` or installation failure.
fix
Ensure your project's `requires_python` is set to `>=3.10` and your environment uses a compatible Python interpreter.
affects: All versions
gotcha`truststore.inject_into_ssl()` performs a global patch on the standard library's `ssl.SSLContext`. While this is often the desired behavior for broad adoption, be aware that it affects all subsequent `SSLContext` creations in the process.
fix
If granular control is needed, you can use `truststore.SSLContext` directly instead of `ssl.SSLContext` for specific connections, or `truststore.extract_from_ssl()` to temporarily revert the global patch.
affects: All versions
deprecatedError handling for unsupported macOS versions (10.7 or earlier) changed in v0.7.0. It now raises an `ImportError` instead of an `OSError` when the module isn't supported on a given macOS system.
fix
Update error handling code to catch `ImportError` when `truststore` is not supported on a given platform, instead of `OSError`.
affects: <0.7.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'truststore'
The 'truststore' package has not been installed in the current Python environment.
fix
pip install truststore
ERROR: Could not find a version that satisfies the requirement truststore (from versions: 0.1.0, 0.1.1, ..., 0.9.1, 0.9.2)
Truststore versions 0.10.0 and above require Python 3.10+. When installing on an older Python version (e.g., 3.9), pip cannot find a compatible release.
fix
For Python 3.9, install a compatible older version: `pip install 'truststore<0.10'`. Alternatively, upgrade your Python environment to 3.10 or newer for the latest truststore features.
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
While truststore is installed, it was not explicitly activated by calling `truststore.inject_into_ssl()` before the requests library (or other libraries relying on `ssl.create_default_context()`) made its network requests.
fix
Add `import truststore; truststore.inject_into_ssl()` at the beginning of your application's entry point, ensuring it runs before any code that needs the patched SSL context.
RuntimeError: truststore not injected into ssl
You attempted to call `truststore.uninstall_from_ssl()` when `truststore.inject_into_ssl()` had not been called previously, or if it was already uninstalled.
fix
Only call `truststore.uninstall_from_ssl()` after a successful call to `truststore.inject_into_ssl()`, and ensure it's not called redundantly.
Upgrade
Version history
0.10.4latest on PyPI · released Aug 12, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
39 hits · last 30 days
node
36
OpenAI (training)
1
Resources
truststore — pip install truststore · libregistry