Sample code for 30+ languages & platforms
Perl 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 Perl Downloads

Chilkat2 Perl
use strict;
use warnings;
use Chilkat2;

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

my $certStore = Chilkat2::CertStore->new;

my $readOnly = 1;
my $success = $certStore->OpenCurrentUserStore($readOnly);
if (!$success) {
    print $certStore->LastErrorText, "\n";
    exit;
}

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