Skip to main content

ACME certificate service for Swarmauri

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_certs_acme


Swarmauri ACME Certificate Service

Community plugin providing an ACME (RFC 8555) certificate service built on top of Swarmauri's certificate interfaces.

Features

  • Implements AcmeCertService, a drop-in CertServiceBase compatible class for Swarmauri workflows.
  • Supports ACME directory discovery, order creation, finalization, and full chain retrieval.
  • Handles RSA and EC key material while exposing capability metadata through supports().
  • Convenience helpers for certificate verification and parsing using cryptography primitives.

Prerequisites

  • Python 3.10 or newer.
  • Existing ACME account key material (PEM encoded) accessible to your Swarmauri runtime.
  • Network access to your chosen ACME directory (defaults to Let's Encrypt production).
  • DNS or HTTP challenge automation handled externally; this service focuses on CSR submission and certificate retrieval.

Installation

# pip
pip install swarmauri_certs_acme

# poetry
poetry add swarmauri_certs_acme

# uv (pyproject-based projects)
uv add swarmauri_certs_acme

Quickstart

The snippet below submits a CSR to Let's Encrypt using AcmeCertService and persists the resulting PEM chain.

import asyncio
from pathlib import Path

from swarmauri_certs_acme import AcmeCertService
from swarmauri_core.crypto.types import KeyRef


async def main() -> None:
    account_key = KeyRef(material=Path("account-key.pem").read_bytes())

    service = AcmeCertService(
        account_key=account_key,
        contact_emails=["admin@example.com"],
    )

    csr_bytes = Path("server.csr").read_bytes()
    certificate_chain = await service.sign_cert(
        csr=csr_bytes,
        ca_key=account_key,  # required by the CertService interface
    )

    Path("server-fullchain.pem").write_bytes(certificate_chain)
    print("Certificate chain written to server-fullchain.pem")


if __name__ == "__main__":
    asyncio.run(main())

CSR Generation Example

AcmeCertService can construct a CSR when provided with private key material and subject metadata:

import asyncio
from pathlib import Path

from swarmauri_certs_acme import AcmeCertService
from swarmauri_core.crypto.types import KeyRef


async def build_csr() -> None:
    account_key = KeyRef(material=Path("account-key.pem").read_bytes())
    host_key = KeyRef(material=Path("server-key.pem").read_bytes())

    service = AcmeCertService(account_key=account_key)

    csr_bytes = await service.create_csr(
        key=host_key,
        subject={"CN": "example.com"},
        san={"dns": ["example.com", "www.example.com"]},
    )
    Path("server.csr").write_bytes(csr_bytes)


if __name__ == "__main__":
    asyncio.run(build_csr())

Verification and Parsing

Use the built-in helpers to inspect returned certificates before deployment:

import asyncio
from pathlib import Path

from swarmauri_certs_acme import AcmeCertService
from swarmauri_core.crypto.types import KeyRef


async def inspect() -> None:
    account_key = KeyRef(material=Path("account-key.pem").read_bytes())
    service = AcmeCertService(account_key=account_key)

    pem_chain = Path("server-fullchain.pem").read_bytes()

    info = await service.verify_cert(pem_chain)
    print("Issuer:", info["issuer"])
    print("Valid until:", info["not_after"])

    metadata = await service.parse_cert(pem_chain)
    print(metadata)


if __name__ == "__main__":
    asyncio.run(inspect())

Best Practices

  • Rotate account keys periodically and store them in a secure vault (KeyRef works with external KMS integrations).
  • When using Let's Encrypt production, respect rate limits and consider staging endpoints during development.
  • Automate DNS/HTTP challenges upstream; this service assumes the order is ready for finalization once the CSR is submitted.
  • Cache successful certificate chains and perform proactive renewals before not_after to avoid downtime.

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_acme-0.3.2.dev7.tar.gz (8.8 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_acme-0.3.2.dev7-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_certs_acme-0.3.2.dev7.tar.gz.

File metadata

  • Download URL: swarmauri_certs_acme-0.3.2.dev7.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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}

File hashes

Hashes for swarmauri_certs_acme-0.3.2.dev7.tar.gz
Algorithm Hash digest
SHA256 633524e01fb62a4c4a2ff206ad619210424c5eec0c65c02395f2a10627a97052
MD5 d910390fc8a93d8eaafaafcc6284e548
BLAKE2b-256 626dd73219854c6ff8114cee4f005a7b186de8e75ae2d5921eff625a6e115f97

See more details on using hashes here.

File details

Details for the file swarmauri_certs_acme-0.3.2.dev7-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_certs_acme-0.3.2.dev7-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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}

File hashes

Hashes for swarmauri_certs_acme-0.3.2.dev7-py3-none-any.whl
Algorithm Hash digest
SHA256 6b91845c9524dab15baaf3895dae7c442396988c06b56a717ec6cf28e427ce5d
MD5 da878077ef49f3444898f3e4e7af3527
BLAKE2b-256 500bf87151a647164c5d8141ef25cdc022d1ed95c2df73f4fc524964189803ce

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