(PHP Extension) Get Public Key from Certificate PEM
Loads a certificate from a PEM file and gets the cert's public key.
<?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('qa_data/certs/someCert.pem');
if ($success != true) {
print $cert->lastErrorText() . "\n";
exit;
}
// Get the certificate's public key:
// pubkey is a CkPublicKey
$pubkey = $cert->ExportPublicKey();
if ($cert->get_LastMethodSuccess() != true) {
print $cert->lastErrorText() . "\n";
exit;
}
print $pubkey->getPem(false) . "\n";
// OK.. we have the public key which can be used in other Chilkat classes/methods...
?>
|