php - openssl_pkey_new 返回空白且没有错误消息
问题描述
我有以下代码:
$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
行之后的任何内容都是空白的。整个页面只是“嗨”,没有别的。
我很困惑它如何不起作用并且没有错误消息..有人有什么想法吗?
编辑:在archlinux上,PHP 5.5.9
解决方案
推荐阅读
- python - 如何解决“TypeError:只能将str(不是“sqlite3.Cursor”)连接到str”
- pywinauto - 如何等待按钮出现在pywinauto中
- kubernetes - 有没有办法在 deployment.yml 文件中动态添加值?
- python - 在 Pandas 或 sklearn 中按索引分组时使用时是否可以打乱数据帧?
- react-native - 如何在 React Native 的组件中直接调用函数
- php - 错误:在 null 上调用成员函数 create(),单元测试(嘲弄)
- jpa - 如何在不使用 JPQL 的情况下选择多行?
- android - 为什么 MediaStore.Images.Media.insertImage 总是将图像保存在 Pictures 文件夹中?
- esri - netcoreapp2.2 不支持 Esri.ArcGISRuntime nuget 包
- ruby - 如何将附加数据设置为哈希中的键