PHP
PHP
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 PHP Downloads
<?php
use Chilkat2\Cert;
use Chilkat2\PrivateKey;
// The LoadFromFile method will automatically detect the file format..
$cert = new Cert();
try {
$cert->LoadFromFile('qa_data/zatca/cert.pem');
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
echo $cert->SubjectCN, "\n";
// Load the private key.
$privKey = new PrivateKey();
try {
$privKey->LoadPemFile('qa_data/zatca/ec-secp256k1-priv-key.pem');
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
echo 'Key Type: ', $privKey->KeyType, "\n";
// Associate the private key with the certificate.
try {
$cert->SetPrivateKey($privKey);
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
echo "Success.\n";