(AutoIt) Find Certificate by Subject O (Organization)
Demonstrates how to find a certificate having the specified subject organization.
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 O = "ICP-Brasil".
$oJson = ObjCreate("Chilkat.JsonObject")
Local $sOrganization = "ICP-Brasil"
$oJson.UpdateString("O",$sOrganization)
$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
|