Easy PEM file parsing in Python.
pem: Easy PEM file parsing
It runs on Python 2.7, 3.4+, and PyPy, has no dependencies, and does not attempt to interpret the certificate data in any way.
It’s born from the need to load keys, certificates, trust chains, and DH parameters from various certificate deployments: some servers (like Apache) expect them to be a separate file, others (like nginx) expect them concatenated to the server certificate and finally some (like HAProxy) expect key, certificate, and chain to be in one file. With pem, your Python application can cope with all of those scenarios:
>>> import pem >>> certs = pem.parse_file("chain.pem") >>> certs [<Certificate(PEM string with SHA-1 digest '...')>, <Certificate(PEM string with SHA-1 digest '...')>] >>> str(certs) '-----BEGIN CERTIFICATE-----\n...'
Additionally to the vanilla parsing code, pem also contains helpers for Twisted that save a lot of boilerplate code.
- pem.certificateOptionsFromFiles() and pem.certificateOptionsFromPEMs() have been removed after three years of deprecation. Please use pem.twisted.certificateOptionsFromFiles() pem.twisted.certificateOptionsFromPEMs() instead.
- Diffie-Hellman support for Twisted older than 14.0 has been removed.
- pem now ships with typing information that can be used by type checkers like mypy.
- PEM objects now have an obj.sha1_hexdigest property with the SHA-1 digest of the stored bytes as a native string. This is the same digest as the one that is used by the PEM objects’ __repr__s.
- PEM objects now have an obj.as_text() method that returns the PEM-encoded content as unicode, always.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size & hash SHA256 hash help||File type||Python version||Upload date|
|pem-18.1.0-py2.py3-none-any.whl (7.9 kB) Copy SHA256 hash SHA256||Wheel||py2.py3||Jun 23, 2018|
|pem-18.1.0.tar.gz (31.0 kB) Copy SHA256 hash SHA256||Source||None||Jun 23, 2018|