Skip to main content

Verify certificates using native system trust stores

Project description

Truststore

Note
This is a fork of the truststore package, which adds additional configuration options for Robocorp projects

PyPI CI

Truststore is a library which exposes native system certificate stores (ie "trust stores") through an ssl.SSLContext-like API. This means that Python applications no longer need to rely on certifi as a root certificate store. Native system certificate stores have many helpful features compared to a static certificate bundle like certifi:

  • Automatically update certificates as new CAs are created and removed
  • Fetch missing intermediate certificates
  • Check certificates against certificate revocation lists (CRLs) to avoid monster-in-the-middle (MITM) attacks
  • Managed per-system rather than per-application by a operations/IT team
  • PyPI is no longer a CA distribution channel 🥳

Right now truststore is a stand-alone library that can be installed globally in your application to immediately take advantage of the benefits in Python 3.10+. Truststore has also been integrated into pip as an opt-in method for verifying HTTPS certificates with truststore instead of certifi.

Long-term the hope is to make truststore the default way to verify HTTPS certificates in pip and to add this functionality into Python itself. Wish us luck!

Installation

Truststore is installed from PyPI with pip:

$ python -m pip install truststore

Truststore requires Python 3.10 or later and supports the following platforms:

User Guide

You can inject truststore into the standard library ssl module so the functionality is used by every library by default. To do so use the truststore.inject_into_ssl() function:

import truststore
truststore.inject_into_ssl()

# Automatically works with urllib3, requests, aiohttp, and more:
import urllib3
http = urllib3.PoolManager()
resp = http.request("GET", "https://example.com")

import aiohttp
http = aiohttp.ClientSession()
resp = await http.request("GET", "https://example.com")

import requests
resp = requests.get("https://example.com")

If you'd like finer-grained control you can create your own truststore.SSLContext instance and use it anywhere you'd use an ssl.SSLContext:

import ssl
import truststore

ctx = truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT)

import urllib3
http = urllib3.PoolManager(ssl_context=ctx)
resp = http.request("GET", "https://example.com")

You can read more in the user guide in the documentation.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robocorp_truststore-0.8.0.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

robocorp_truststore-0.8.0-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file robocorp_truststore-0.8.0.tar.gz.

File metadata

  • Download URL: robocorp_truststore-0.8.0.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.5

File hashes

Hashes for robocorp_truststore-0.8.0.tar.gz
Algorithm Hash digest
SHA256 92d8f3d6dc10b9b7825683ae8dc1e134a0c3ade81c99554e3ddd4eafa59a8acf
MD5 9fdb1ee3733d37cea6c093b0b2bc9aaf
BLAKE2b-256 cf4f44fdd4f2e5f89562409bf1ef50d2b984d8e7ed21119dd93b354457e59658

See more details on using hashes here.

File details

Details for the file robocorp_truststore-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for robocorp_truststore-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f298f733c997f024393c93526f8d9eac893aa56809e92edfd109ea31f622231f
MD5 596c38a9d492e3a60151d011331e5c11
BLAKE2b-256 321b5ec042c02441dc15e31dcd06d9af063ebf9843cc3ca14a5eff7e0dbaad57

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page