How can I decode a pem-encoded (base64) certificate with Python? For example this here from github.com:
-----BEGIN CERTIFICATE-----
MIIHKjCCBhKgAwIBAgIQDnd2i
You can use pyasn1 and pyasn1-modules packages to parse this kind of data. For instance:
from pyasn1_modules import pem, rfc2459
from pyasn1.codec.der import decoder
substrate = pem.readPemFromFile(open('cert.pem'))
cert = decoder.decode(substrate, asn1Spec=rfc2459.Certificate())[0]
print(cert.prettyPrint())
Read the docs for pyasn1 for the rest.