Registry / auth-security / pyasn1-modules

pyasn1-modules

JSON →
library0.4.2pypypi✓ verified 29d ago

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.

pip install pyasn1-modules
INSTALL
IMPORT
SIG · PYASN1-MODULES
P
pyasn1-modules
auth-securitypythonv0.4.2
Install
1.9s avg
Import
66ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.4.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.070s · 20.5MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.9s · import 0.062s · 21MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

rfc2459
✓ from pyasn1_modules import rfc2459
✗ import rfc2459
Direct imports without the pyasn1_modules prefix will fail.

Decoding a DER-encoded X.509 certificate using pyasn1-modules.

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)
Debug
Known issues
breakingDropped support for Python 2.7, 3.6, and 3.7 in version 0.4.0.
fix
Upgrade your Python environment to version 3.8 or later.
affects: 0.4.0 and later
gotchaImporting modules directly without the pyasn1_modules prefix will result in ImportError.
fix
Use the correct import statement: from pyasn1_modules import <module_name>.
affects: All versions
gotchaEnsure that pyasn1 is installed, as it is a required dependency.
fix
Install pyasn1 using pip install pyasn1.
affects: All versions
breakingThe pyasn1 decoder encountered an unexpected ASN.1 tag during decoding. This typically indicates that the input DER-encoded data does not conform to the specified ASN.1 schema (e.g., rfc2459.Certificate), or that the data itself is malformed. This can also occur if the version of pyasn1-modules providing the schema is incompatible with the structure of the data.
fix
Verify the integrity and correctness of the input DER-encoded data. Ensure it strictly adheres to the X.509 (RFC 2459) standard if `rfc2459.Certificate()` is used. Update both `pyasn1` and `pyasn1-modules` to their latest stable versions (`pip install --upgrade pyasn1 pyasn1-modules`) to ensure compatibility with modern certificate structures, or if parsing a non-standard certificate, ensure the correct `asn1Spec` is provided.
affects: All versions of pyasn1 and pyasn1-modules
breakingDecoding a DER-encoded object with an incorrect ASN.1 schema or a malformed input will result in a 'pyasn1.error.PyAsn1Error' indicating 'TagSet not in asn1Spec'.
fix
Ensure that the DER-encoded input data is valid and conforms to the expected ASN.1 schema. Verify that the 'asn1Spec' provided to the decoder (e.g., 'decoder.decode(data, asn1Spec=...)') accurately represents the structure of the input data. Inspect the 'TagSet' mentioned in the error message to understand where the mismatch occurs, as it often points to an unexpected ASN.1 type or structure in the input.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pyasn1_modules'
The `pyasn1-modules` package is not installed in the current Python environment or a specific sub-module cannot be found due to an incomplete installation or environment issue.
fix
Ensure `pyasn1-modules` is installed: `pip install pyasn1-modules`. If using a specific protocol module, ensure it's imported correctly, e.g., `from pyasn1_modules import rfc2459`.
pkg_resources.DistributionNotFound: The 'pyasn1-modules>=0.2.1' distribution was not found and is required by google-auth
A dependency, often `google-auth`, requires a specific version of `pyasn1-modules` that is either not installed, or `pkg_resources` cannot locate it due to conflicts, often when using `conda` alongside `pip` or having multiple Python installations.
fix
Force reinstall `pyasn1-modules` and potentially `pyasn1` to resolve potential conflicts: `pip install --upgrade --force-reinstall pyasn1 pyasn1-modules`. If using `conda`, consider creating a new environment and installing dependencies solely with `pip` or ensuring `conda` and `pip` are in sync.
TypeError: __init__() got an unexpected keyword argument 'openType'
This error typically occurs due to an incompatibility between the installed versions of `pyasn1` and `pyasn1-modules`, where `pyasn1-modules` is trying to use an API feature (like `openType`) that is not present or has changed in the installed `pyasn1` version.
fix
Upgrade both `pyasn1` and `pyasn1-modules` to their latest compatible versions: `pip install --upgrade pyasn1 pyasn1-modules`.
pyasn1.error.PyAsn1Error: Component type not defined
This error occurs during decoding when an ASN.1 sequence or set has components that are not explicitly defined in the `asn1Spec` provided to the decoder, making it unable to determine the type of the encountered data.
fix
Ensure that the `asn1Spec` passed to the `decoder.decode()` function fully defines all potential components and their types within the ASN.1 structure being decoded. Explicitly define each component type within the `Sequence` or `Set` object that acts as the `asn1Spec`.
pyasn1.error.PyAsn1Error: 'not in asn1Spec: None'
This error indicates that the `pyasn1` decoder was unable to match a tag from the incoming BER/DER/CER serialized data with any of the expected ASN.1 types defined in the `asn1Spec` provided, often because the `asn1Spec` is missing or incomplete for the data being decoded.
fix
Provide a complete and correct `asn1Spec` (an ASN.1 type object from `pyasn1` or `pyasn1-modules`) to the `decoder.decode()` function that accurately reflects the structure of the data being deserialized. For custom types, ensure they are correctly tagged and passed to the decoder.
Upgrade
Version history
0.4.2latest on PyPI · released Mar 28, 2025
Audit
Dependencies
pyasn1requiredCore library for ASN.1 data structures
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
pyasn1-modules — pip install pyasn1-modules · libregistry