I make some code to generate public and private code. It was working ok on one machine, but on other server it is causing "Internal Server Error".
private function keyGen()
{
if(is_file($this::pubK_path) )
exec("rm ".$this::pubK_path);
if(is_file($this::privK_path) )
exec("rm ".$this::privK_path);
$config = array(
"digest_alg" => "sha512",
"private_key_bits" => 512,
"private_key_type" => OPENSSL_KEYTYPE_RSA
);
// Create the private and public key
$this->key = openssl_pkey_new($config);
$pubkey=openssl_pkey_get_details($this->key);
$this->pubkey=$pubkey["key"];
$privK=null;
openssl_pkey_export($this->key, $privK,$this->pass);
file_put_contents($this::privK_path, $privK);
file_put_contents($this::pubK_path, $this->pubkey);
}
Sadly I didn't find any information about this error in any log. I only find that it is caused by this line:
$pubkey=openssl_pkey_get_details($this->key);
Key is generated properly - when I deleted openssl_pkey_get_details, private key was saved in file.
Any ideas what is wrong, or other method to get public key?