PHP ActiveX
PHP ActiveX
Load Certificate from .cer and Private Key from .pem
See more Certificates Examples
Load a certificate from a .cer and its associated private key from a .pem.Chilkat PHP ActiveX Downloads
<?php
$success = 0;
$cert = new COM("Chilkat.Cert");
$success = $cert->LoadFromFile('C:/certs_and_keys/Certificate.cer');
if ($success == 0) {
print $cert->LastErrorText . "\n";
exit;
}
$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";
?>