Sample code for 30+ languages & platforms
CkPython

Find Certificate by Subject O (Organization)

See more Cert Store Examples

Demonstrates how to find a certificate having the specified subject organization.

Note: Requires Chilkat v10.1.2 or later.

Chilkat CkPython Downloads

CkPython
import sys
import chilkat

success = False

certStore = chilkat.CkCertStore()

# This opens the Current User certificate store on Windows,
# On MacOS and iOS it opens the default Keychain.
readOnly = False
success = certStore.OpenCurrentUserStore(readOnly)
if (success == False):
    print(certStore.lastErrorText())
    sys.exit()

# Find the certificate having a Subject O = "ICP-Brasil".
json = chilkat.CkJsonObject()
organization = "ICP-Brasil"
json.UpdateString("O",organization)

cert = chilkat.CkCert()
success = certStore.FindCert(json,cert)
if (success == True):
    # Show the full distinguished name of the certificate.
    print("Found: " + cert.subjectDN())
else:
    print("Not found.")