(PHP ActiveX) Load Certificate from .cer and Private Key from .pem
Load a certificate from a .cer and its associated private key from a .pem.
<?php
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.Cert')
$cert = new COM("Chilkat.Cert");
$success = $cert->LoadFromFile('C:/certs_and_keys/Certificate.cer');
if ($success == 0) {
print $cert->LastErrorText . "\n";
exit;
}
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.StringBuilder')
$sbPem = new COM("Chilkat.StringBuilder");
$success = $sbPem->LoadFile('C:/certs_and_keys/PrivateKey.pem','utf-8');
if ($success == 0) {
print 'Failed to load private key PEM' . "\n";
exit;
}
$success = $cert->SetPrivateKeyPem($sbPem->getAsString());
if ($success == 0) {
print $cert->LastErrorText . "\n";
exit;
}
print 'The certificate and associated private key are now loaded and ready for signing.' . "\n";
?>
|