Skip to main content

Easy PEM file parsing in Python.

Project description

pem: Easy PEM file parsing

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

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, 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[0])
'-----BEGIN CERTIFICATE-----\n...'

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

pem’s documentation lives at Read the Docs, the code on GitHub.

Release Information

18.1.0 (2018-06-23)

Backward-incompatible changes:

  • 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.

Deprecations:

none

Changes:

  • 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.

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.

Project details


Download files

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

Source Distribution

pem-18.1.0.tar.gz (31.0 kB view details)

Uploaded Source

Built Distribution

pem-18.1.0-py2.py3-none-any.whl (7.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pem-18.1.0.tar.gz.

File metadata

  • Download URL: pem-18.1.0.tar.gz
  • Upload date:
  • Size: 31.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pem-18.1.0.tar.gz
Algorithm Hash digest
SHA256 9aa71ff6fb354b341cea346e952993d8d1082b8774f2d92bf2246bfcdbced08f
MD5 d042b26674b40fbe55d17c5edbc05f5e
BLAKE2b-256 123dcedc1324a738b43b02970960c6580fe531400b44fa310e56e19319d9f734

See more details on using hashes here.

File details

Details for the file pem-18.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pem-18.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 53aab93ebbec110e07274822cdbcd5fcc278fa8fc6e74762027797b8e141365b
MD5 f8d4924a07d989d7550810d0ebfb7a5f
BLAKE2b-256 6bea772d0bbcfb897e58538a81de6c8b85d818dddf883d7b114c8c0467ec6fff

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page