Skip to main content

Easy PEM file parsing in Python.

Project description

pem: Easy PEM file parsing

Documentation Status CI Status Coverage Checked with mypy https://www.irccloud.com/invite-svg?channel=%23cryptography-dev&hostname=irc.freenode.net&port=6697&ssl=1 Code style: black

pem is an MIT-licensed Python module for parsing and splitting of PEM files, i.e. Base64-encoded DER keys and certificates.

It runs on Python 2.7, and 3.5+, 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[0])
'-----BEGIN CERTIFICATE-----\n...'

Additionally to the vanilla parsing code, pem also contains helpers for Twisted that save a lot of boilerplate code.

pem is available from PyPI, its documentation lives at Read the Docs, the code on GitHub.

Release Information

21.2.0 (2021-04-07)

Backward-incompatible changes:

none

Deprecations:

none

Changes:

  • Added support for pem.OpenSSLTrustedCertificate (-----BEGIN TRUSTED CERTIFICATE-----), as defined in openssl x509 manual. #28

Full changelog.

Credits

pem is written and maintained by Hynek Schlawack.

The development is kindly supported by Variomedia AG.

A full list of contributors can be found on GitHub’s overview.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pem, version 21.2.0
Filename, size File type Python version Upload date Hashes
Filename, size pem-21.2.0-py2.py3-none-any.whl (8.8 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size pem-21.2.0.tar.gz (35.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page