Perl Requires Chilkat v10.1.2+
Chilkat2 Perl
Find Certificate by SHA1 Thumbprint
See more Cert Store Examples
Demonstrates how to find a certificate having the specified hexadecimal SHA1 thumbprint.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 specific SHA1 thumbprint.
my $json = Chilkat2::JsonObject->new;
my $hexThumbprint = '767192374BE3C1512D2CB80734926D40E96D6DC2';
$json->UpdateString('thumbprint', $hexThumbprint);
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";
}