Sample code for 30+ languages & platforms
Perl

Import a Certificate (.cer file) into a Windows Certificate Store

See more Certificates Examples

Demonstrates how to import a certificate (without private key) into a Windows certificate store.

Chilkat Perl Downloads

Chilkat2 Perl
use strict;
use warnings;
use Chilkat2;

my $cert = Chilkat2::Cert->new;

my $success = $cert->LoadFromFile('qa_data/certs/example.cer');
if (!$success) {
    print $cert->LastErrorText, "\n";
    exit;
}

my $certStoreCU = Chilkat2::CertStore->new;
my $readOnlyFlag = 0;

# "CurrentUser" and "My" are the exact keywords to select your user account's certificate store.
$success = $certStoreCU->OpenWindowsStore('CurrentUser', 'My', $readOnlyFlag);
if (!$success) {
    print "Failed to open the CurrentUser/My certificate store for read/write.\n";
    exit;
}

# Import the certificate into the CurrentUser/My certificate store.
$success = $certStoreCU->AddCertificate($cert);
if (!$success) {
    print $certStoreCU->LastErrorText, "\n";
    exit;
}

print 'Imported ', $cert->SubjectCN, "\n";
print "Success.\n";