0
我做了一些代码来生成公共和私人代码。它在一台机器上工作正常,但在其他服务器上它导致“内部服务器错误”。openssl_pkey_get_details导致内部服务器错误
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);
}
很遗憾,我没有在任何日志中找到有关此错误的任何信息。我只发现它是由这一行造成的:
$pubkey=openssl_pkey_get_details($this->key);
关键是正确生成 - 当我删除openssl_pkey_get_details,私钥保存在文件中。
任何想法什么是错的,或其他方法来获得公钥?
您是否尝试过更多?你有没有发现'openssl_error_string()'的错误? –