openssl_pkey_new返回空白,没有错误消息

时间:2019-03-20 00:07:26

标签: php

我有以下代码:

    $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;

由于某种原因,openssl_pkey_new根本不返回任何内容-甚至没有错误。

打印“ hi”,debug_to_console仅将值输出到控制台。 $config打印良好,但$res行之后的内容为空白。整个页面都是“ hi”,仅此而已。

我很困惑它如何不起作用并且没有错误消息..任何人有任何想法吗?

编辑: 在archlinux上,PHP 5.5.9

0 个答案:

没有答案
相关问题