Код:
#include <Array.au3>
Global Const $CAPICOM_LOCAL_MACHINE_STORE = 1
Global Const $CAPICOM_CURRENT_USER_STORE = 2
Global $iOption = $CAPICOM_LOCAL_MACHINE_STORE ;Change only this to one of above options
$aCerts = _Certificates_Get($iOption)
If @error Then
Exit MsgBox(16, @ScriptName, 'Unable to create CAPICOM.Store object' & @CRLF & @CRLF & ' ==> EXIT')
EndIf
_ArrayDisplay($aCerts)
Func _Certificates_Get($iOption)
Local Const $sOption = ($iOption = $CAPICOM_CURRENT_USER_STORE ? 'My' : 'Root')
Local $oCertStore = ObjCreate('CAPICOM.Store')
If Not IsObj($oCertStore) Then
Return SetError(1, 0, 0)
EndIf
$oCertStore.Open($iOption, $sOption, 0)
Local $oCerts = $oCertStore.Certificates
If Not IsObj($oCerts) Then
Return SetError(2, 0, 0)
EndIf
Local $iC = 1
Local $aCerts[$oCerts.Count + 1][8] = [[$oCerts.Count, 'IssuerName', 'SerialNumber', 'SubjectName', 'Version', 'ValidFromDate', 'ValidToDate', 'PrivateKey UniqueContainerName']]
For $oCert In $oCerts
$aCerts[$iC][1] = $oCert.IssuerName
$aCerts[$iC][2] = $oCert.SerialNumber
$aCerts[$iC][3] = $oCert.SubjectName
$aCerts[$iC][4] = $oCert.Version
$aCerts[$iC][5] = _Certificates_DateFormat($oCert.ValidFromDate)
$aCerts[$iC][6] = _Certificates_DateFormat($oCert.ValidToDate)
If $oCert.HasPrivateKey() Then
$aCerts[$iC][7] = $oCert.PrivateKey.UniqueContainerName
EndIf
$iC += 1
Next
Return $aCerts
EndFunc
Func _Certificates_DateFormat($sDate)
Local $aDate = StringRegExp($sDate, '(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)', 3)
If UBound($aDate) < 6 Then
Return SetError(1, 0, $sDate)
EndIf
Return StringFormat('%02i/%02i/%04i %02i:%02i:%02i', $aDate[2], $aDate[1], $aDate[0], $aDate[3], $aDate[4], $aDate[5])
EndFunc