(PHP ActiveX) ZATCA Load Certificate and Private Key from PEM Files
Demonstrates how to load a certificate and private key from a pair of PEM files.
<?php
// The LoadFromFile method will automatically detect the file format..
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.Cert')
$cert = new COM("Chilkat.Cert");
$success = $cert->LoadFromFile('qa_data/zatca/cert.pem');
if ($success != 1) {
print $cert->LastErrorText . "\n";
exit;
}
print $cert->SubjectCN . "\n";
// Load the private key.
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.PrivateKey')
$privKey = new COM("Chilkat.PrivateKey");
$success = $privKey->LoadPemFile('qa_data/zatca/ec-secp256k1-priv-key.pem');
if ($success != 1) {
print $privKey->LastErrorText . "\n";
exit;
}
print 'Key Type: ' . $privKey->KeyType . "\n";
// Associate the private key with the certificate.
$success = $cert->SetPrivateKey($privKey);
if ($success != 1) {
print $cert->LastErrorText . "\n";
exit;
}
print 'Success.' . "\n";
?>
|