asn1crypto

1.5.1 · active · verified Sat Mar 28

A fast, pure Python library for parsing and serializing ASN.1 structures, including private keys, public keys, certificates, and various PKCS standards. Current version: 1.5.1. Release cadence: irregular, with the latest release on March 15, 2022. ([pypi.org](https://pypi.org/project/asn1crypto/?utm_source=openai))

Warnings

Install

Imports

Quickstart

A basic example demonstrating how to load, parse, and access details of an X.509 certificate using asn1crypto.

from asn1crypto import x509

# Load a certificate from a file
with open('certificate.pem', 'rb') as f:
    cert_data = f.read()

# Parse the certificate
cert = x509.Certificate.load(cert_data)

# Access certificate details
print(cert.subject.native)  # Print the subject of the certificate
print(cert.serial_number)   # Print the serial number of the certificate

view raw JSON →