Sample code for 30+ languages & platforms
CkPython Requires Chilkat v11.8.0+

Example: Crypt2.AddPemSource method

Demonstrates how to call the AddPemSource method.

Chilkat CkPython Downloads

CkPython
import sys
import chilkat

success = False

crypt = chilkat.CkCrypt2()
success = False

#  Do public-key decryption (RSA)
crypt.put_CryptAlgorithm("pki")

#  ...
#  ...
#  ...

#  Load a PEM file that has a certificate and its private key.  The 2nd argument of LoadPemFile
#  is the password of the private key.  (Pass an empty string if the private key is not encrypted.)
pemPath = "c:/my_pem_files/a.pem"
pemPassword = "secret1"
pem = chilkat.CkPem()
success = pem.LoadPemFile(pemPath,pemPassword)
if (success == False):
    print(pem.lastErrorText())
    sys.exit()

success = crypt.AddPemSource(pem)
if (success == False):
    print(crypt.lastErrorText())
    sys.exit()

#  Add as many PEM sources as desired...
#  Each call to AddPemSource adds more certificates to the ones already added.
pemPath = "c:/my_pem_files/b.pem"
pemPassword = "secret2"
pem2 = chilkat.CkPem()
success = pem2.LoadPemFile(pemPath,pemPassword)
if (success == False):
    print(pem2.lastErrorText())
    sys.exit()

success = crypt.AddPemSource(pem2)
if (success == False):
    print(crypt.lastErrorText())
    sys.exit()

#  ...
#  ...