openssl - extracting public key

From: Date: Tue, 02 Mar 2004 06:18:44 +0000
Subject: openssl - extracting public key
Groups: php.general 
Request: Send a blank email to php-general+get-179206@lists.php.net to get a copy of this message
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

« previous php.general (#179206) next »