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

Uploaded Python 3

File details

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

File metadata

  • Download URL: swarmauri_certs_acme-0.3.3.dev17.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.dev17.tar.gz
Algorithm Hash digest
SHA256 7990ee885177bc5dd6d7a36bd033af86b8ab21c499ef90fc1acfdeb81d656e17
MD5 faf2ef4b13b3e55f2312c7b0ff74fd2c
BLAKE2b-256 2217062bbcda0ae48cea13d6d060e8ca356a89610b7b71362dbf3eef0ceaa56f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_certs_acme-0.3.3.dev17-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.dev17-py3-none-any.whl
Algorithm Hash digest
SHA256 d5ad5fcd4800784367da17996d07c6db6c783f4b539c67e9a1c800391d9a82a6
MD5 97f9b7abf4363b5c73c8e72b418cf948
BLAKE2b-256 f1b86f778dc2b7d9d21bf3b1d6f5826e9418fc92dd3d9d9084178d74b7ffefcd

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