AutoIt
AutoIt
Load PEM and List Certificates
Demonstrates how to load a PEM containing certificates and accesses each individual certificate.Chilkat AutoIt Downloads
Local $bSuccess = False
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$bSuccess = False
$oPem = ObjCreate("Chilkat.Pem")
; Load the .p7b from a file.
$bSuccess = $oPem.LoadPemFile("/Users/chilkat/testData/p7b/cacert_mozilla.pem")
If ($bSuccess <> True) Then
ConsoleWrite($oPem.LastErrorText & @CRLF)
Exit
EndIf
Local $i
Local $iNumCerts = $oPem.NumCerts
If ($iNumCerts = 0) Then
ConsoleWrite((("Error: Expected the PEM to contain certificates.")) & @CRLF)
Exit
EndIf
; Access each certificate and show the Subject CN (Common Name)
For $i = 1 To $iNumCerts
Local $oCert = $oPem.GetCert($i - 1)
ConsoleWrite($i & ": " & $oCert.SubjectCN & @CRLF)
Next