[英]openssl_pkey_get_details cause internal server error
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. 密钥生成正确-当我删除openssl_pkey_get_details时,私钥已保存在文件中。
Any ideas what is wrong, or other method to get public key? 任何想法有什么问题,还是其他获取公钥的方法?
Sadly I didn't find any information about this error in any log.
遗憾的是,我没有在任何日志中找到有关此错误的任何信息。
You can use openssl_error_string()
to find out what is openssl_pkey_new()
returning, you should see a false
or any other OpenSSL
error (from here ). 您可以使用
openssl_error_string()
找出openssl_pkey_new()
返回的内容,您应该会看到一个false
或任何其他OpenSSL
错误(从此处开始 )。 Like: 喜欢:
<?php
// lets assume you just called an openssl function that failed
while ($msg = openssl_error_string())
echo $msg . "<br />\n";
?>
Then it should be easy to find the problem (you can update this thread with the error). 然后应该很容易找到问题(您可以使用错误更新此线程)。
Hope it helps! 希望能帮助到你!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.