Skip to main content

OCSP certificate verification service for Swarmauri.

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_certs_ocspverify


swarmauri_certs_ocspverify

OCSP-based certificate verification service for the Swarmauri SDK.

This package provides an implementation of an ICertService that checks certificate revocation status using the Online Certificate Status Protocol (OCSP) defined in RFC 6960 while remaining compatible with X.509 certificate guidelines from RFC 5280.

Features

  • Parse PEM certificates to extract subject, issuer and OCSP responder URLs.
  • Verify certificate status via OCSP responders advertised in the certificate's Authority Information Access extension.

Prerequisites

  • Python 3.10 or newer.
  • Leaf certificate PEM to inspect and validate.
  • Issuer (intermediate) certificate PEM required to build the OCSP request.
  • Network access to the OCSP responder URLs exposed in the certificate's Authority Information Access extension.
  • Optional: trust root bundle if performing additional validation on issuer metadata alongside OCSP results.

Installation

# pip
pip install swarmauri_certs_ocspverify

# poetry
poetry add swarmauri_certs_ocspverify

# uv (pyproject-based projects)
uv add swarmauri_certs_ocspverify

Usage

Perform an OCSP status check for a leaf certificate using its issuer certificate:

import asyncio
from pathlib import Path

from swarmauri_certs_ocspverify import OcspVerifyService


async def main() -> None:
    service = OcspVerifyService()

    leaf_cert = Path("leaf.pem").read_bytes()
    issuer_cert = Path("issuer.pem").read_bytes()

    verification = await service.verify_cert(
        cert=leaf_cert,
        intermediates=[issuer_cert],
        check_revocation=True,
    )

    if verification["valid"]:
        print("Certificate status: GOOD")
    else:
        print("Certificate status:", verification["reason"])
    print("Next update:", verification.get("next_update"))


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

Parsing OCSP Metadata

Use parse_cert to confirm which OCSP responder URLs are embedded and to inspect the validity window:

import asyncio
from pathlib import Path

from swarmauri_certs_ocspverify import OcspVerifyService


async def describe() -> None:
    service = OcspVerifyService()
    leaf_cert = Path("leaf.pem").read_bytes()

    metadata = await service.parse_cert(leaf_cert)
    print("Subject:", metadata["subject"])
    print("Issuer:", metadata["issuer"])
    print("OCSP URLs:", metadata.get("ocsp_urls", []))


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

Best Practices

  • Cache issuer certificates alongside leaf certificates so OCSP requests can be constructed quickly.
  • Respect OCSP responder rate limits; consider backoff and caching GOOD responses until next_update.
  • Combine OCSP checks with CRL fallbacks for authorities that support multiple revocation mechanisms.
  • Log reason and timestamp fields from the verification output to aid in incident response and compliance reporting.

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_ocspverify-0.9.2.dev6.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file swarmauri_certs_ocspverify-0.9.2.dev6.tar.gz.

File metadata

  • Download URL: swarmauri_certs_ocspverify-0.9.2.dev6.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","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_ocspverify-0.9.2.dev6.tar.gz
Algorithm Hash digest
SHA256 da3a96264e0135e294aa807bc09d6dff9b389880c76281ae4429008a3fbfab7d
MD5 959567004e2b85cf8d7382fa559474c6
BLAKE2b-256 8b0a027d4d5f15e5e6ccbc2e558806a03a9655c848d6eaad8c4eadaff7e6077e

See more details on using hashes here.

File details

Details for the file swarmauri_certs_ocspverify-0.9.2.dev6-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_certs_ocspverify-0.9.2.dev6-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","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_ocspverify-0.9.2.dev6-py3-none-any.whl
Algorithm Hash digest
SHA256 285cc2ba33da3dd7aa5a8435abd0ed8419cea9b24761fa8f6c424558e513ebe1
MD5 d4dcf92d50cedcc4224d17ef66e7f9ce
BLAKE2b-256 1f8adff184a3e6942875040d4b00f7e3d2478f00ab3909943b56fafa399c684a

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