I have the following code:
$config = array(
"digest_alg" => "sha512",
"private_key_bits" => $size,
"private_key_type" => OPENSSL_KEYTYPE_RSA,
"config" => "/home/user/openssl/ssl/openssl.cnf"
);
// Create the private and public key
echo "hi";
debug_to_console($config);
$res = openssl_pkey_new($config);
debug_to_console($res);
while ($msg = openssl_error_string()){
echo $msg . "<br />\n";
}
// Extract the private key from $res to $privKey
openssl_pkey_export($res, $privKey);
// Extract the public key from $res to $pubKey
$pubKey = openssl_pkey_get_details($res);
$pubKey = $pubKey["key"];
echo "hello";
var_dump($pubKey);
var_dump($privKey);
return $pubKey;
For some reason, openssl_pkey_new
does not return anything at all - not even an error.
"hi" prints out, and debug_to_console
just outputs the values to the console. $config
is printed fine, but anything after the $res
line is blank. The entire page is just "hi" and nothing else.
I'm quite confused how its not working and theres no error message.. anyone have any ideas?
EDIT: On archlinux, PHP 5.5.9