Access your OS root certificates with utmost ease
Project description
Wassima 🔒
I named this library after my wife, whom I trust the most. ❤️
This project offers you a great alternative to the MPL licensed certifi.
This project allows you to access your original operating system trust store, thus helping you to verify the remote peer certificates. It automatically fallback to an embedded trust store generated from the CCADB trusted source.
It works as-is out-of-the-box for any operating systems out there. Available on PyPy and Python 3.7+
✨ Installation
Using pip:
pip install wassima -U
Get started
A) Create a SSLContext
import wassima
ctx = wassima.create_default_ssl_context()
# ... The context magically contain your system root CAs, the rest is up to you!
B) Retrieve individually root CAs in a binary form (DER)
import wassima
certs = wassima.root_der_certificates()
# ... It contains a list of certificate represented in bytes
C) Retrieve individually root CAs in a string form (PEM)
import wassima
certs = wassima.root_pem_certificates()
# ... It contains a list of certificate represented in string
D) Retrieve a single bundle (concatenated) list of PEM certificates like certifi does
import wassima
bundle = wassima.generate_ca_bundle()
# ... It contains a string with all of your root CAs!
# It is not a path but the file content itself.
E) Register your own CA in addition to the system's
import wassima
# register CA only accept string PEM (one at a time!)
wassima.register_ca(open("./myrootca.pem", "r").read())
bundle = wassima.generate_ca_bundle()
# ... It contains a string with all of your root CAs, PLUS your own 'myrootca.pem'.
# It is not a path but the file content itself.
F) Use a hybrid trust store (OS + embedded CCADB bundle)
import wassima
# By default, only your OS trust store is used (with the embedded CCADB
# bundle as a fallback when the OS exposes nothing). Pass `hybrid_store=True`
# to force concatenating the embedded CCADB bundle in addition to the OS
# trust store. Useful in containers or appliances that ship with a slim or
# outdated system trust store.
ctx = wassima.create_default_ssl_context(hybrid_store=True)
# Available on every public top-level entry point:
wassima.root_der_certificates(hybrid_store=True)
wassima.root_pem_certificates(hybrid_store=True)
wassima.generate_ca_bundle(hybrid_store=True)
On Linux/BSD, when the system trust store has not been updated for at least
3 years, hybrid_store=True is implicitly applied so that the result is
never silently outdated.
The output of root_der_certificates() (and the upper helpers built on top
of it) is always deduplicated: a given DER certificate is guaranteed to
appear at most once in the resulting list, regardless of how many OS stores
or directories it lives in.
⏱️ Cache invalidation
For performance reasons the result of root_der_certificates() /
root_pem_certificates() is cached. By default, the cache automatically
expires every 12 hours so that any change to the OS trust store (e.g. a CA
rotated overnight by your IT department) is picked up without having to
restart the process.
You can override the TTL at runtime, pass 0 to disable caching entirely:
import wassima
# Force a refresh every hour:
wassima.set_cache_ttl(3600)
# Disable caching (every call recomputes):
wassima.set_cache_ttl(0)
# Restore the default (12 hours):
wassima.set_cache_ttl(wassima.DEFAULT_CACHE_TTL_SECONDS)
Setting a new TTL invalidates any pending cached result immediately.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wassima-2.1.0.tar.gz.
File metadata
- Download URL: wassima-2.1.0.tar.gz
- Upload date:
- Size: 135.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
709f375c778d9be84568d802d1e1b62a2ed3942b1fa4c83830533a69cf36c243
|
|
| MD5 |
bd4c1693342c5d88b21fd89d858b940f
|
|
| BLAKE2b-256 |
58e010e0ff85dc4d48b5000aa76567dfacf33b9518c2fadd410e850e213c36b9
|
Provenance
The following attestation bundles were made for wassima-2.1.0.tar.gz:
Publisher:
CI.yml on jawah/wassima
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wassima-2.1.0.tar.gz -
Subject digest:
709f375c778d9be84568d802d1e1b62a2ed3942b1fa4c83830533a69cf36c243 - Sigstore transparency entry: 1489139702
- Sigstore integration time:
-
Permalink:
jawah/wassima@7bfae0095f3b8425d621d64131931dd6faa9e2f0 -
Branch / Tag:
refs/tags/2.1.0 - Owner: https://github.com/jawah
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@7bfae0095f3b8425d621d64131931dd6faa9e2f0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file wassima-2.1.0-py3-none-any.whl.
File metadata
- Download URL: wassima-2.1.0-py3-none-any.whl
- Upload date:
- Size: 128.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e8bc4b439f91f4da24bd2260be662fcb42d1cc439d7678420237d314e55a854
|
|
| MD5 |
859d927d657924536529b4ce81faac01
|
|
| BLAKE2b-256 |
53f9077b0aacd337c31d3f97eef7acfa89bcd522360b56614f961af84db0a3ca
|
Provenance
The following attestation bundles were made for wassima-2.1.0-py3-none-any.whl:
Publisher:
CI.yml on jawah/wassima
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wassima-2.1.0-py3-none-any.whl -
Subject digest:
4e8bc4b439f91f4da24bd2260be662fcb42d1cc439d7678420237d314e55a854 - Sigstore transparency entry: 1489140035
- Sigstore integration time:
-
Permalink:
jawah/wassima@7bfae0095f3b8425d621d64131931dd6faa9e2f0 -
Branch / Tag:
refs/tags/2.1.0 - Owner: https://github.com/jawah
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@7bfae0095f3b8425d621d64131931dd6faa9e2f0 -
Trigger Event:
push
-
Statement type: