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.dev4.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.dev4-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.dev4.tar.gz.

File metadata

File hashes

Hashes for swarmauri_certs_local_ca-0.3.0.dev4.tar.gz
Algorithm Hash digest
SHA256 31e3f442b54b1dd8e0155dff6056a537099b5095518ad1b04ffbdbfd6da9dbef
MD5 7b75609494745a742907402fd97028a2
BLAKE2b-256 d1496f0084d17a2970c4773d5e3f406a6ec059e86afd6eeb37612d22b2ae0ebd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for swarmauri_certs_local_ca-0.3.0.dev4-py3-none-any.whl
Algorithm Hash digest
SHA256 b989caf71cd9f3c9ac7df1708c930f17121f277f75f4232fabdb7a549d0ed3fd
MD5 0fc0a4abf22284e2115d98f72c31d391
BLAKE2b-256 cd63d086205e5c47fa71d2f8a803a78c3de5a7ca49153d6ad11782c8bb73a647

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