Perl Requires Chilkat v10.1.2+
Chilkat2 Perl
Find Certificate by Subject O (Organization)
See more Cert Store Examples
Demonstrates how to find a certificate having the specified subject organization.Chilkat Perl Downloads
use strict;
use warnings;
use Chilkat2;
my $certStore = Chilkat2::CertStore->new;
# This opens the Current User certificate store on Windows,
# On MacOS and iOS it opens the default Keychain.
my $readOnly = 0;
my $success = $certStore->OpenCurrentUserStore($readOnly);
if (!$success) {
print $certStore->LastErrorText, "\n";
exit;
}
# Find the certificate having a Subject O = "ICP-Brasil".
my $json = Chilkat2::JsonObject->new;
my $organization = 'ICP-Brasil';
$json->UpdateString('O', $organization);
my $cert = Chilkat2::Cert->new;
$success = $certStore->FindCert($json, $cert);
if ($success) {
# Show the full distinguished name of the certificate.
print 'Found: ', $cert->SubjectDN, "\n";
} else {
print "Not found.\n";
}