(Tcl) Find Certificate by Subject OU (Organizational Unit)
Demonstrates how to find a certificate having the specified subject organizational unit (OU).
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 Subject OU = "Secretaria da Receita Federal do Brasil - RFB".
set json [new_CkJsonObject]
set ou "Secretaria da Receita Federal do Brasil - RFB"
CkJsonObject_UpdateString $json "OU" $ou
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
|