简体   繁体   English

openssl_pkey_get_details导致内部服务器错误

[英]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.

相关问题 XAMPP PHP OPENSSL openssl_pkey_get_details()崩溃了网页 - XAMPP PHP OPENSSL openssl_pkey_get_details() crashes webpage openssl_pkey_get_details()期望参数1为资源,给定布尔值 - openssl_pkey_get_details() expects parameter 1 to be resource, boolean given openssl_pkey_get_details($ res)不返回公共指数 - openssl_pkey_get_details($res) returns no public exponent PHP和“ openssl_pkey_get_details()期望参数1为资源的私钥” - Private Key with PHP and “openssl_pkey_get_details() expects parameter 1 to be resource” “ openssl_pkey_get_details”仅返回“ bits”,“ key”和“ type”值(无法访问[rsa]) - `openssl_pkey_get_details` only returning `bits`, `key` and `type` values (can't access [rsa]) openssl_pkey_get_private返回false - openssl_pkey_get_private returning false openssl_pkey_get_public没有打开公钥,“没有起始行”错误 - openssl_pkey_get_public not open public key, “no start line” error openssl_pkey_get_public返回0 - openssl_pkey_get_public return 0 PHP Openssl_pkey_get_private()结果取决于openssl - PHP Openssl_pkey_get_private() result depends on openssl 是什么导致PayPal的AdaptivePayments API返回内部服务器错误。 请检查服务器日志以获取详细信息”? - What would cause PayPal's AdaptivePayments API to return a “ internal server error. please check the server logs for details”?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM