Skip to main content

Python certificate chain resolver

Licence CI Docs codecov Downloads Python) PyPI - Wheel PyPI Code style: black

Resolve and obtain the complete certificate chain from the leaf, intermediate(s) to the root of a x509 certificate using the CLI or the python API.

The library provides an easy to use API to access each property of a certificate chain and the important metadata of a certificate. The library also exposes a CLI for resolving and inspecting certificate chains from the command line.

Support

  • PKCS7, PEM and DER formats
  • LetsEncrypt certificates
  • Including the root certificate using the system CA bundle or custom bundle
  • Python2 (but not for much longer..)

Installation

Pypi package

$ pip install cert-chain-resolver

CLI Usage

For more options and examples see the read the docs or pass the --help flag.

The bundle gets written to stdout and the chain information to stderr.

from source:

$ python -m cert_chain_resolver.cli --include-root certificate.crt > bundle.crt
$ cat certificate.crt | python -m cert_chain_resolver.cli --include-root > bundle.crt

from PIP

 $ cert_chain_resolver --include-root certificate.crt > bundle.crt
 1. <Cert common_name="github.com" subject="CN=github.com,O=GitHub\, Inc.,L=San Francisco,ST=California,C=US" issuer="CN=DigiCert SHA2 High Assurance Server CA,OU=www.digicert.com,O=DigiCert Inc,C=US">
 2. <Cert common_name="DigiCert SHA2 High Assurance Server CA" subject="CN=DigiCert SHA2 High Assurance Server CA,OU=www.digicert.com,O=DigiCert Inc,C=US" issuer="CN=DigiCert High Assurance EV Root CA,OU=www.digicert.com,O=DigiCert Inc,C=US">
 3. <Cert common_name="DigiCert High Assurance EV Root CA" subject="CN=DigiCert High Assurance EV Root CA,OU=www.digicert.com,O=DigiCert Inc,C=US" issuer="CN=DigiCert High Assurance EV Root CA,OU=www.digicert.com,O=DigiCert Inc,C=US">

Python API

Make sure to read the documentation for more examples and options.

from cert_chain_resolver.api import resolve

with open('cert.pem', 'rb') as f:
   fb = f.read()
   chain = resolve(fb)
>>>
for cert in chain:
  print(cert)
  print(cert.export())  # Export the certificate in PEM format

<Cert common_name="cert-chain-resolver.remcokoopmans.com" subject="CN=cert-chain-resolver.remcokoopmans.com" issuer="CN=R3,O=Let's Encrypt,C=US">
"-----BEGIN CERTIFICATE-----...."
<Cert common_name="R3" subject="CN=R3,O=Let's Encrypt,C=US" issuer="CN=DST Root CA X3,O=Digital Signature Trust Co.">
"-----BEGIN CERTIFICATE-----...."
<Cert common_name="DST Root CA X3" subject="CN=DST Root CA X3,O=Digital Signature Trust Co." issuer="CN=DST Root CA X3,O=Digital Signature Trust Co.">
"-----BEGIN CERTIFICATE-----...."

Dependencies

  • cryptography

After cloning the repository

Install dependencies

$ make

Development

bootstrap

$ make

Testing

Unit testing

$ make tests

Re-run tests on file changes:

$ make tests TEST_ARGS="-- -f"

Formatting

$ make format

Metadata

Release files for cert-chain-resolver 1.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cert-chain-resolver 1.4.2
File Size Uploaded Provenance Actions
cert_chain_resolver-1.4.2.tar.gz 18.7 kB With provenance Details for cert_chain_resolver-1.4.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cert-chain-resolver 1.4.2
File Interpreter ABI Platform Actions
cert_chain_resolver-1.4.2-py3-none-any.whl Python 3 none any Details for cert_chain_resolver-1.4.2-py3-none-any.whl

Total release size: 41.9 kB

Release files / cert_chain_resolver-1.4.2.tar.gz

Download URL cert_chain_resolver-1.4.2.tar.gz
Size 18.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e9d343128010154aa7b764cf4af0c0c6922a15f468555c97e38aefbc05b39a2f
BLAKE2b-256 checksum
How to use checksums
9f63ae86cea87108f7ad6e42bf9f1108516c04a3133274c240a8d2f35662d1f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / cert_chain_resolver-1.4.2-py3-none-any.whl

Download URL cert_chain_resolver-1.4.2-py3-none-any.whl
Size 23.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f1258c3136e13911ea559997afc09b52647d7b95a9df10dba20d160e067e4e23
BLAKE2b-256 checksum
How to use checksums
85c29923ffff1b89ca6a9f7492168611149786ed157120d33b691fb613701096
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Security for cert-chain-resolver 1.4.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cert_chain_resolver-1.4.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page