Perl
Perl
ZATCA Load Certificate and Private Key from PEM Files
See more ZATCA Examples
Demonstrates how to load a certificate and private key from a pair of PEM files.Chilkat Perl Downloads
use strict;
use warnings;
use Chilkat2;
# The LoadFromFile method will automatically detect the file format..
my $cert = Chilkat2::Cert->new;
my $success = $cert->LoadFromFile('qa_data/zatca/cert.pem');
if (!$success) {
print $cert->LastErrorText, "\n";
exit;
}
print $cert->SubjectCN, "\n";
# Load the private key.
my $privKey = Chilkat2::PrivateKey->new;
$success = $privKey->LoadPemFile('qa_data/zatca/ec-secp256k1-priv-key.pem');
if (!$success) {
print $privKey->LastErrorText, "\n";
exit;
}
print 'Key Type: ', $privKey->KeyType, "\n";
# Associate the private key with the certificate.
$success = $cert->SetPrivateKey($privKey);
if (!$success) {
print $cert->LastErrorText, "\n";
exit;
}
print "Success.\n";