Hello,
I'm trying to use the openssl function and seem to be having a problem extracting the public key from the keypair generated by openssl_pkey_new. Is there a function to do this in PHP?


Here is the sample code.

<?php

$pubkey = "";
$privkey = "";
$keypair = "";
$privkeyout ="";
$pubkeyout = "";

// Generate a new private (and public) key pair
$keypair = openssl_pkey_new();

//openssl_get_publickey expects a mixed certificate parameter

// begin problem area
$pubkey =  openssl_get_publickey($keypair);
//end problem area

//openssl_get_publickey expects a  mixed key
$privkey = openssl_get_privatekey($keypair);

openssl_pkey_export($privkey, $privkeyout);
openssl_pkey_export($pubkey, $pubkeyout);

echo "Private Key<br>";
 var_dump($privkeyout);
echo "<br>Public Key<br>";
 var_dump($pubkeyout);

openssl_free_key($keypair);
?>

Thanks,
Tony



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to