Sample code for 30+ languages & platforms
CkPython

Get Certificate's Public Key

Loads a certificate from PEM and gets the public key.

Chilkat CkPython Downloads

CkPython
import sys
import chilkat

success = False

cert = chilkat.CkCert()

strPem = "-----BEGIN CERTIFICATE----- ..."

success = cert.LoadPem(strPem)
if (success == False):
    print(cert.lastErrorText())
    sys.exit()

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

# You can now use the public key object however it is needed,
# and access its various properties and methods..

print(pubKey.getXml())