(PHP Extension) Load Certificate from .cer and Private Key from .pem
Load a certificate from a .cer and its associated private key from a .pem.
<?php
include("chilkat.php");
// Use "chilkat_9_5_0.php" for versions of Chilkat < 10.0.0
$cert = new CkCert();
$success = $cert->LoadFromFile('C:/certs_and_keys/Certificate.cer');
if ($success == false) {
print $cert->lastErrorText() . "\n";
exit;
}
$sbPem = new CkStringBuilder();
$success = $sbPem->LoadFile('C:/certs_and_keys/PrivateKey.pem','utf-8');
if ($success == false) {
print 'Failed to load private key PEM' . "\n";
exit;
}
$success = $cert->SetPrivateKeyPem($sbPem->getAsString());
if ($success == false) {
print $cert->lastErrorText() . "\n";
exit;
}
print 'The certificate and associated private key are now loaded and ready for signing.' . "\n";
?>
|