Sample code for 30+ languages & platforms
Tcl

Find Certificate by Email Address

Locate the certificate containing the specified email address in either the RFC822 Name or the Subject.

Note: This example requires Chilkat v10.1.2 or later.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

set certStore [new_CkCertStore]

# This opens the Current User certificate store on Windows,
# On MacOS and iOS it opens the default Keychain.
set readOnly 1
set success [CkCertStore_OpenCurrentUserStore $certStore $readOnly]
if {$success == 0} then {
    puts [CkCertStore_lastErrorText $certStore]
    delete_CkCertStore $certStore
    exit
}

# Locate the certificate containing the specified email address in either the RFC822 Name or the Subject.
set json [new_CkJsonObject]

set email_address "harold@example.com"
CkJsonObject_UpdateString $json "email" $email_address

set cert [new_CkCert]

set success [CkCertStore_FindCert $certStore $json $cert]
if {$success == 1} then {
    # Show the full distinguished name of the certificate.
    puts "Found: [CkCert_subjectDN $cert]"
} else {
    puts "Not found."
}


delete_CkCertStore $certStore
delete_CkJsonObject $json
delete_CkCert $cert