Skip to main content

X.509 certificate service for Swarmauri

Project description

swarmauri_certs_x509

X.509 certificate service plugin for Swarmauri using the cryptography library.

Features

  • Create CSRs
  • Issue self-signed certificates
  • Sign certificates with a CA
  • Verify certificate chains

RFC References

  • RFC 2986 – PKCS #10 Certification Request Syntax
  • RFC 5280 – Internet X.509 Public Key Infrastructure Certificate and CRL Profile

Usage

The snippet below demonstrates creating a certificate authority (CA), issuing a leaf certificate, and verifying the resulting chain.

import asyncio
from swarmauri_certs_x509 import X509CertService
from swarmauri_core.crypto.types import KeyRef, KeyType, KeyUse, ExportPolicy
from cryptography.hazmat.primitives.asymmetric import ed25519
from cryptography.hazmat.primitives import serialization

svc = X509CertService()

def make_key() -> KeyRef:
    sk = ed25519.Ed25519PrivateKey.generate()
    pem = sk.private_bytes(
        serialization.Encoding.PEM,
        serialization.PrivateFormat.PKCS8,
        serialization.NoEncryption(),
    )
    return KeyRef(
        kid="k1",
        version=1,
        type=KeyType.ED25519,
        uses=(KeyUse.SIGN,),
        export_policy=ExportPolicy.SECRET_WHEN_ALLOWED,
        material=pem,
        public=None,
        tags={},
    )

ca_key = make_key()
ca_cert = asyncio.run(svc.create_self_signed(ca_key, {"CN": "Example CA"}))

leaf_key = make_key()
csr = asyncio.run(svc.create_csr(leaf_key, {"CN": "example.org"}))
leaf_cert = asyncio.run(svc.sign_cert(csr, ca_key, ca_cert=ca_cert))
result = asyncio.run(svc.verify_cert(leaf_cert, trust_roots=[ca_cert]))
assert result["valid"]

Testing

Run unit, performance, and functional tests with:

uv run --package swarmauri_certs_x509 --directory standards/swarmauri_certs_x509 pytest

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_x509-0.2.0.dev4.tar.gz (8.0 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_x509-0.2.0.dev4-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_certs_x509-0.2.0.dev4.tar.gz.

File metadata

File hashes

Hashes for swarmauri_certs_x509-0.2.0.dev4.tar.gz
Algorithm Hash digest
SHA256 cb60923338dc2f4a88a78252756d457c18488468fbad1ec0338918d30c947309
MD5 bef77b7bd244679108244666132b915c
BLAKE2b-256 78e9733cca1e1e786e8fbf26e788875e678f6819dc1e187754641893b2d775c4

See more details on using hashes here.

File details

Details for the file swarmauri_certs_x509-0.2.0.dev4-py3-none-any.whl.

File metadata

File hashes

Hashes for swarmauri_certs_x509-0.2.0.dev4-py3-none-any.whl
Algorithm Hash digest
SHA256 e7453c6051b3c68118390a3a8624d6dec79989e3e274944e457c098ae7d3637f
MD5 4592858630d91ac86509783f30f3c6b1
BLAKE2b-256 4b647e12a9bfa7d6598f91c33e7e423ea4a2a7568e0f8db823ee284329503f83

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