Local CA certificate service for Swarmauri
Project description
Swarmauri Certs Local CA
A local certificate authority implementing the ICertService interface for issuing and verifying X.509 certificates. Useful for development and testing environments.
Features:
- CSR generation with subject alternative names
- Self-signed certificate issuance
- Signing CSRs to produce leaf certificates
- Basic certificate verification and parsing
- Optional IDNA support for internationalized DNS names
Installation
pip install swarmauri_certs_local_ca
Usage
Below is a minimal end‑to‑end example that issues and verifies a leaf
certificate signed by a local certificate authority. The helper function
_key creates the KeyRef objects required by the service.
import asyncio
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from swarmauri_certs_local_ca import LocalCaCertService
from swarmauri_core.crypto.types import ExportPolicy, KeyRef, KeyType, KeyUse
def _key(name: str) -> KeyRef:
sk = rsa.generate_private_key(public_exponent=65537, key_size=2048)
pem = sk.private_bytes(
serialization.Encoding.PEM,
serialization.PrivateFormat.PKCS8,
serialization.NoEncryption(),
)
return KeyRef(
kid=name,
version=1,
type=KeyType.RSA,
uses=(KeyUse.SIGN,),
export_policy=ExportPolicy.SECRET_WHEN_ALLOWED,
material=pem,
)
async def main() -> None:
svc = LocalCaCertService()
ca_key = _key("ca")
leaf_key = _key("leaf")
# Create a certificate signing request for the leaf key.
csr = await svc.create_csr(leaf_key, {"CN": "leaf"})
# Sign the CSR with the CA key to produce a leaf certificate.
cert = await svc.sign_cert(csr, ca_key, issuer={"CN": "ca"})
# Verify the newly issued certificate.
result = await svc.verify_cert(cert)
print(result["valid"]) # True
asyncio.run(main())
Entry Point
The service registers under the swarmauri.cert_services entry point as LocalCaCertService.
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 swarmauri_certs_local_ca-0.3.0.dev3.tar.gz.
File metadata
- Download URL: swarmauri_certs_local_ca-0.3.0.dev3.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60ebc648dcabca42218990c0ca228be83ddc96a091bac07ea19a800a8c803d65
|
|
| MD5 |
ced9ecdfc90af099db1dbb9dae44e8d9
|
|
| BLAKE2b-256 |
d1cfe5ca5fe6d6d51d657b28a351850a23a103aa833fa8495ac8770297ecfe5c
|
File details
Details for the file swarmauri_certs_local_ca-0.3.0.dev3-py3-none-any.whl.
File metadata
- Download URL: swarmauri_certs_local_ca-0.3.0.dev3-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c1d8c80c3732fec55f2e2aaed48ed2e614207190606bdf6b5d55bd5f0113bc0
|
|
| MD5 |
0b956e28f034ce003f99f929d6bdc711
|
|
| BLAKE2b-256 |
faf815256e72377b04495eb2e83375360d29d6cd9094c53f0990b465eb5b7fb6
|