Sample code for 30+ languages & platforms
Chilkat2-Python

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 Chilkat2-Python Downloads

Chilkat2-Python
import sys
import chilkat2

success = False

cert = chilkat2.Cert()

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

pubkey = chilkat2.PublicKey()
cert.GetPublicKey(pubkey)

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