Sample code for 30+ languages & platforms
Chilkat2-Python

Get Certificate's Public Key

Loads a certificate from PEM and gets the public key.

Chilkat Chilkat2-Python Downloads

Chilkat2-Python
import sys
import chilkat2

success = False

cert = chilkat2.Cert()

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

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

pubKey = chilkat2.PublicKey()
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())