pyasn1-modules
pyasn1-modules is a collection of ASN.1-based protocol modules for Python, built upon the pyasn1 library. The current version is 0.4.2, released on March 28, 2025. The library is actively maintained, with updates addressing compatibility and support for newer Python versions.
Warnings
- breaking Dropped support for Python 2.7, 3.6, and 3.7 in version 0.4.0.
- gotcha Importing modules directly without the pyasn1_modules prefix will result in ImportError.
- gotcha Ensure that pyasn1 is installed, as it is a required dependency.
Install
-
pip install pyasn1-modules
Imports
- rfc2459
from pyasn1_modules import rfc2459
Quickstart
from pyasn1_modules import rfc2459
from pyasn1.codec.der import decoder
# Example DER-encoded certificate (incomplete for brevity)
der_encoded_cert = b'...'
# Decode the certificate
cert, _ = decoder.decode(der_encoded_cert, asn1Spec=rfc2459.Certificate())
# Access certificate fields
subject = cert['tbsCertificate']['subject']
print('Subject:', subject)