(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
// The version number (9_5_0) should match version of the Chilkat extension used, omitting the micro-version number.
// For example, if using Chilkat v9.5.0.48, then include as shown here:
include("chilkat_9_5_0.php");
$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";
?>
|