Truststore

0.10.4 · active · verified Thu Apr 09

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.

Warnings

Install

Imports

Quickstart

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}")

view raw JSON →