(AutoIt) 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.
$oCertStore = ObjCreate("Chilkat.CertStore")
; This opens the Current User certificate store on Windows,
; On MacOS and iOS it opens the default Keychain.
Local $bReadOnly = False
Local $bSuccess = $oCertStore.OpenCurrentUserStore($bReadOnly)
If ($bSuccess = False) Then
ConsoleWrite($oCertStore.LastErrorText & @CRLF)
Exit
EndIf
; Find the certificate having a Subject OU = "Secretaria da Receita Federal do Brasil - RFB".
$oJson = ObjCreate("Chilkat.JsonObject")
Local $sOu = "Secretaria da Receita Federal do Brasil - RFB"
$oJson.UpdateString("OU",$sOu)
$oCert = ObjCreate("Chilkat.Cert")
$bSuccess = $oCertStore.FindCert($oJson,$oCert)
If ($bSuccess = True) Then
; Show the full distinguished name of the certificate.
ConsoleWrite("Found: " & $oCert.SubjectDN & @CRLF)
Else
ConsoleWrite("Not found." & @CRLF)
EndIf
|