(PHP Extension) Duplicate openssl pkey -in private.pem -pubout -out pubkey.pem
How to output the public part of a private key:
Demonstrates how to duplicate this OpenSSL command:
openssl pkey -in private.pem -pubout -out pubkey.pem
<?php
include("chilkat.php");
// Use "chilkat_9_5_0.php" for versions of Chilkat < 10.0.0
$pkey = new CkPrivateKey();
// Load the private key from an PEM file:
$success = $pkey->LoadPemFile('private.pem');
if ($success != true) {
print $pkey->lastErrorText() . "\n";
exit;
}
// pubKey is a CkPublicKey
$pubKey = $pkey->GetPublicKey();
if ($pkey->get_LastMethodSuccess() == false) {
print $pkey->lastErrorText() . "\n";
exit;
}
$success = $pubKey->SavePemFile(false,'pubKey.pem');
if ($success != true) {
print $pubKey->lastErrorText() . "\n";
exit;
}
print 'Success.' . "\n";
?>
|