Sample code for 30+ languages & platforms
Chilkat2-Python

Get Public Key from Certificate PEM

See more Certificates Examples

Loads a certificate from a PEM file and gets the cert's public key.

Chilkat Chilkat2-Python Downloads

Chilkat2-Python
import sys
import chilkat2

success = False

cert = chilkat2.Cert()

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

# Get the certificate's public key:
pubkey = chilkat2.PublicKey()
cert.GetPublicKey(pubkey)

print(pubkey.GetPem(False))

# OK.. we have the public key which can be used in other Chilkat classes/methods...