Skip to main content

Local CA certificate service for Swarmauri

Project description

Swamauri Logo

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


Download files

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

Source Distribution

swarmauri_certs_local_ca-0.3.0.dev3.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swarmauri_certs_local_ca-0.3.0.dev3-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_certs_local_ca-0.3.0.dev3.tar.gz.

File metadata

File hashes

Hashes for swarmauri_certs_local_ca-0.3.0.dev3.tar.gz
Algorithm Hash digest
SHA256 60ebc648dcabca42218990c0ca228be83ddc96a091bac07ea19a800a8c803d65
MD5 ced9ecdfc90af099db1dbb9dae44e8d9
BLAKE2b-256 d1cfe5ca5fe6d6d51d657b28a351850a23a103aa833fa8495ac8770297ecfe5c

See more details on using hashes here.

File details

Details for the file swarmauri_certs_local_ca-0.3.0.dev3-py3-none-any.whl.

File metadata

File hashes

Hashes for swarmauri_certs_local_ca-0.3.0.dev3-py3-none-any.whl
Algorithm Hash digest
SHA256 4c1d8c80c3732fec55f2e2aaed48ed2e614207190606bdf6b5d55bd5f0113bc0
MD5 0b956e28f034ce003f99f929d6bdc711
BLAKE2b-256 faf815256e72377b04495eb2e83375360d29d6cd9094c53f0990b465eb5b7fb6

See more details on using hashes here.

Supported by

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