Sample code for 30+ languages & platforms
CkPython

Get Certificate Public Key from PEM

See more Certificates Examples

Demonstrates how to load a PEM file containing a certificate and access the public key.

Chilkat CkPython Downloads

CkPython
import sys
import chilkat

success = False

cert = chilkat.CkCert()

success = cert.LoadFromFile("qa_data/pem/my_cert.pem")
if (success == False):
    print(cert.lastErrorText())
    sys.exit()

pubkey = chilkat.CkPublicKey()
cert.GetPublicKey(pubkey)

# Examine the public key as XML..
print(pubkey.getXml())