OpenSSL和PHP [英] Openssl and PHP
问题描述
我正在尝试使用PHP加载由openssl cli工具生成的私钥. 我使用了以下命令和PHP代码:
Im trying to load a private key generated by the openssl cli tool with PHP. I used the following command and PHP code:
openssl genrsa -des3 4096 -out private.key
openssl genrsa -des3 4096 -out private.key
if (!($key = openssl_pkey_get_private("file://private.key", "password")));
{
return false;
}
我确定密码正确并且文件也是PEM格式的,但它始终返回false.我在做什么错了?
I'm sure the password is correct and the file is also PEM formatted, but it keeps returning false. What am I doing wrong?
预先感谢, 乔里.
推荐答案
请注意,文档中的file://path/to/file.pem
表示文件协议+文件路径.在像OS这样的UNIX中,这类似于file:///rsa_private_key.pem
.路径字符串中有三个斜杠,而不是两个.并且file://
不能省略.
Please note that file://path/to/file.pem
in documentation means file protocol + file path. In UNIX like OS, that is something like file:///rsa_private_key.pem
. There is THREE slashes in the path string, not TWO. And file://
cannot be omitted.
这篇关于OpenSSL和PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!