spiffe-tls package (experimental)
Overview
The spiffe-tls package, part of the py-spiffe library, streamlines the
establishment of secure TLS connections using SPIFFE certificates. Powered
by pyOpenSSL, it provides straightforward utilities for configuring TLS clients
and servers. Currently experimental, spiffe-tls facilitates the seamless integration of SPIFFE for the automatic
management of X.509 certificates and CA trust bundles via X509Source from
the spiffe package.
Key Features
- TLS connections with SPIFFE ID validation.
- Mutual TLS (MTLS) support for authenticated client-server communication.
- Customizable server and client TLS configurations.
- Standard library-compatible SSL context with automatic certificate refresh.
Quick Start
Server Setup
# Create a TLS server with SPIFFE-based MTLS
from spiffetls import listen, ListenOptions
from spiffe import SpiffeId, X509Source
from spiffetls.mode import ServerTlsMode
from spiffetls.tlsconfig.authorize import authorize_id
x509_source = X509Source()
options = ListenOptions(
tls_mode=ServerTlsMode.MTLS,
authorize_fn=authorize_id(SpiffeId("spiffe://example.org/client-service")),
)
listener = listen("localhost:8443", x509_source, options)
Client Connection
# Establish a secure connection to a TLS server
from spiffetls import dial
from spiffe import SpiffeId, X509Source
from spiffetls.tlsconfig.authorize import authorize_id
x509_source = X509Source()
conn = dial(
"localhost:8443",
x509_source,
authorize_fn=authorize_id(SpiffeId("spiffe://example.org/server")),
)
Using with Standard HTTP Libraries
For integration with standard Python HTTP libraries (like requests, httpx, urllib3), use SpiffeSSLContext:
# Use SPIFFE authentication with httpx
from spiffetls import SpiffeSSLContext
from spiffe import X509Source
import httpx
x509_source = X509Source()
# Create an SSL context that automatically refreshes certificates
ssl_context = SpiffeSSLContext(x509_source, use_system_trusted_cas=True)
# Use with httpx
client = httpx.Client(verify=ssl_context)
response = client.get("https://api.example.org/data")
The SpiffeSSLContext provides a standard library-compatible interface that automatically refreshes X.509 SVIDs as they rotate, without requiring manual updates to the SSL context. This is particularly useful for long-running applications.
Authorization Functions
The package supports custom authorization functions for additional certificate validation:
authorize_any(): Accepts any SPIFFE ID.authorize_id(): Validates a specific SPIFFE ID.authorize_one_of(): Allows any ID from a set of allowed SPIFFE IDs.authorize_member_of(): Permits any ID from a specific trust domain.
Contributing
We welcome contributions to the spiffe-tls package! Please see
our contribution guidelines for more
details. For feedback and issues, please submit them through
the GitHub issue tracker.
Metadata
Release files for spiffe-tls 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spiffe_tls-0.4.1.tar.gz | 21.2 kB | Without provenance | Details for spiffe_tls-0.4.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spiffe_tls-0.4.1-py3-none-any.whl | Python 3 | none | any | Details for spiffe_tls-0.4.1-py3-none-any.whl |
Total release size: 48.1 kB
Release files / spiffe_tls-0.4.1.tar.gz
| Download URL | spiffe_tls-0.4.1.tar.gz |
|---|---|
| Size | 21.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dc2012f1fed6b73ddd5b7a4ccb7599b341f2863fcb85c9fd3a7340a43f189c13
|
|
BLAKE2b-256 checksum How to use checksums |
d105b228494ec606317737d83ec7c97c45e9e1905234c4fff56f970dab867b01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / spiffe_tls-0.4.1-py3-none-any.whl
| Download URL | spiffe_tls-0.4.1-py3-none-any.whl |
|---|---|
| Size | 27.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
036a9bd9f1531a6bbebdadbe2b32191d31d7daf346e0d3713bc6ba96375f0722
|
|
BLAKE2b-256 checksum How to use checksums |
8031f2da2b201935b2c35b58b5c1b9981d1ce0ae3336a05fec1c20517f69a890
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for spiffe-tls 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.