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.3.dev3.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.3.dev3-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_certs_acme-0.3.3.dev3.tar.gz.

File metadata

  • Download URL: swarmauri_certs_acme-0.3.3.dev3.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.3.dev3.tar.gz
Algorithm Hash digest
SHA256 6a38266f9e3c3046acdc801ca88a3912b378b7f4d47b795dc916db46ee44f2bf
MD5 2ebc71d1adba87274abdf49a7a0d319c
BLAKE2b-256 1710a1785f87f50b75b4094c73bf1731f0ee51a03fc8fa3d0abefb09561e9b89

See more details on using hashes here.

File details

Details for the file swarmauri_certs_acme-0.3.3.dev3-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_certs_acme-0.3.3.dev3-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.3.dev3-py3-none-any.whl
Algorithm Hash digest
SHA256 b188fcd93a7f861356fc4b5a56e5a1547151844967ed976efbf2cefe744357fb
MD5 46a3de00b2b6aac73875161270284bdf
BLAKE2b-256 4df623c8a561b5cce95a0d4293a9d28bb7d09feee514b26ec817d5aee38320a4

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