Sample code for 30+ languages & platforms
PHP Requires Chilkat v10.1.2+

List Certificates in the Current User Certificate Store (Windows Only)

See more Certificates Examples

This is a Windows-only example to list the certificates in the current-user certificate store (located in the Windows Registry).

Chilkat PHP Downloads

Chilkat2 PHP
<?php

use Chilkat2\Cert;
use Chilkat2\CertStore;

// This is a Windows-only example because it lists the certificates
// stored in the Windows Current User Certificate Store located in the
// Windows Registry.

$certStore = new CertStore();

$readOnly = true;
try {
    $certStore->OpenCurrentUserStore($readOnly);
} catch (\Chilkat2\Exception $e) {
    echo $e->getMessage(), "\n";
    exit;
}

$cert = new Cert();
$numCerts = $certStore->NumCertificates;
$i = 0;
while ($i < $numCerts) {
    $certStore->GetCert($i, $cert);
    echo 'DN = ', $cert->SubjectDN, "\n";
    echo 'Email = ', $cert->SubjectE, "\n";
    $i = $i + 1;
}