(Tcl) Find Certificate by SHA1 Thumbprint
Demonstrates how to find a certificate having the specified hexadecimal SHA1 thumbprint.
Note: Requires Chilkat v10.1.2 or later.
load ./chilkat.dll
set certStore [new_CkCertStore]
# This opens the Current User certificate store on Windows,
# On MacOS and iOS it opens the default Keychain.
set readOnly 0
set success [CkCertStore_OpenCurrentUserStore $certStore $readOnly]
if {$success == 0} then {
puts [CkCertStore_lastErrorText $certStore]
delete_CkCertStore $certStore
exit
}
# Find the certificate having a specific SHA1 thumbprint.
set json [new_CkJsonObject]
set hexThumbprint "767192374BE3C1512D2CB80734926D40E96D6DC2"
CkJsonObject_UpdateString $json "thumbprint" $hexThumbprint
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
|