CkPython
CkPython
Load Certificate from .cer and Private Key from .pem
See more Certificates Examples
Load a certificate from a .cer and its associated private key from a .pem.Chilkat CkPython Downloads
import sys
import chilkat
success = False
cert = chilkat.CkCert()
success = cert.LoadFromFile("C:/certs_and_keys/Certificate.cer")
if (success == False):
print(cert.lastErrorText())
sys.exit()
sbPem = chilkat.CkStringBuilder()
success = sbPem.LoadFile("C:/certs_and_keys/PrivateKey.pem","utf-8")
if (success == False):
print("Failed to load private key PEM")
sys.exit()
success = cert.SetPrivateKeyPem(sbPem.getAsString())
if (success == False):
print(cert.lastErrorText())
sys.exit()
print("The certificate and associated private key are now loaded and ready for signing.")