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

Uploaded Python 3

File details

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

File metadata

  • Download URL: swarmauri_certs_acme-0.3.3.dev22.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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.dev22.tar.gz
Algorithm Hash digest
SHA256 bcb64305be79aae14a0e7c95e440e4b5fa79317fcf49af5fc7da83b642a5c720
MD5 5061c92290e15992d520e3903eb7048e
BLAKE2b-256 21733e6a35f68287420b079394917d5de15a82105caa0364ebf14840a6d81328

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_certs_acme-0.3.3.dev22-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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.dev22-py3-none-any.whl
Algorithm Hash digest
SHA256 02982e1fdeb09d82b50dcf5d52b58f96ee49aea2c3011ce3ed8085f9c67e8c6a
MD5 d00ee22a3b42cd4ae636aaaa13830476
BLAKE2b-256 4748a4bf06a71106a1e1b2c2a13db67e4199f452692d2d82622c79a04e7f460f

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