windows 调用 openssl_pkey_new() 时 xampp openssl 错误;
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4719939/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
xampp openssl errors when calling openssl_pkey_new();
提问by xenador
so I am trying to get openssl working on my windows installation of xampp(1.7.3) which is built with OpenSSL 0.9.8l. This is only my second time to install openssl on an *amp install but the first time went swimmingly(it was a wamp install on the same machine, but I found that xampp was more my style so I switched).
所以我试图让 openssl 在我的 xampp(1.7.3) 的 Windows 安装上工作,它是用 OpenSSL 0.9.8l 构建的。这只是我第二次在 *amp 安装上安装 openssl,但第一次顺利进行(这是在同一台机器上的 wamp 安装,但我发现 xampp 更符合我的风格,所以我换了)。
when I attempted a simple setup script:
当我尝试一个简单的安装脚本时:
var_dump(getenv('OPENSSL_CONF'));
$privateKey = openssl_pkey_new();
while($message = openssl_error_string()){
echo $message.'<br />'.PHP_EOL;
}
I got a returned message:
我收到一条回复消息:
error:02001003:system library:fopen:No such process
error:2006D080:BIO routines:BIO_new_file:no such file
error:0E064002:configuration file routines:CONF_load:system lib
I read the php.net page that informed me about the possibility of needing to set the openssl.cnf and ssleay.dll environment constants, I tried that but nothing changed.
我阅读了 php.net 页面,该页面告诉我需要设置 openssl.cnf 和 ssleay.dll 环境常量的可能性,我尝试过,但没有任何改变。
A var_dump
of OPENSSL_CONF
resulted in the path: C:/xampp/apache/bin/openssl.cnf
which is correct for my machine.
A var_dump
ofOPENSSL_CONF
导致路径:C:/xampp/apache/bin/openssl.cnf
这对我的机器是正确的。
I checked that the path to the php directory (where ssleay32.dll and libeay32.dll are located) was defined in my path system var, and it was not, so I defined it, restarted my machine, and in the process rebooted apache, but no change in the error messages.
我检查了 php 目录的路径(ssleay32.dll 和 libeay32.dll 所在的位置)是否在我的路径系统 var 中定义,但它没有,所以我定义了它,重新启动了我的机器,并在此过程中重新启动了 apache,但错误消息没有变化。
my version of xampp did not come with a php_openssl.dll and as such I believe the php.ini document should exclude it from the list of available .dlls as it did when I checked. I believe xampp comes compiles with a zend based extension instead.
我的 xampp 版本没有附带 php_openssl.dll,因此我相信 php.ini 文档应该像我检查时那样将它从可用的 .dll 列表中排除。我相信 xampp 会使用基于 zend 的扩展来编译。
I am able to start openssl from the xampp gui, and I sucessfully created a private/public key pair.
我可以从 xampp gui 启动 openssl,并且我成功地创建了一个私钥/公钥对。
phpinfo() reports:
phpinfo() 报告:
openssl OpenSSL support enabled
OpenSSL Library Version OpenSSL
0.9.8l 5 Nov 2009 OpenSSL Header Version OpenSSL 0.9.8l 5 Nov 2009
openssl OpenSSL 支持已启用
OpenSSL 库版本 OpenSSL
0.9.8l 2009 年 11 月 5 日 OpenSSL 标头版本 OpenSSL 0.9.8l 2009 年 11 月 5 日
there was an old ssleay.dll and libeay32.dll from the wamp install I presume in my systems directory but I have deleted them since. (restarted after, and rebooted apache)
我假设在我的系统目录中有一个来自 wamp 安装的旧 ssleay.dll 和 libeay32.dll,但我已经删除了它们。(之后重新启动,并重新启动apache)
I tried copying the openssl.cnf to the default directory'C:\usr\local\ssl\openssl.cnf' no change.
我尝试将 openssl.cnf 复制到默认目录 'C:\usr\local\ssl\openssl.cnf' 没有变化。
I also read thisthread and thisthread but the answers given were relevant but failed to help or were non-existant.
我也阅读了这个线程和这个线程,但给出的答案是相关的,但没有帮助或不存在。
Anyone have any ideas on what I should check next or anything obvious that I missed?
任何人都对我接下来应该检查的内容或我错过的任何明显内容有任何想法?
回答by Archimedix
Maybe you need to specify the path to your openssl.cnf
file when calling openssl_pkey_new()
:
也许您需要openssl.cnf
在调用时指定文件的路径openssl_pkey_new()
:
$configArgs = array(
'config' => '/etc/openssl/openssl.cnf',
// ...
);
openssl_pkey_new($configArgs);
You may also need to specify additional settings in $configArgs
for the function to work (have not tested that lately).
See also http://php.net/manual/en/function.openssl-csr-new.phpfor a description of supported further configuration arguments.
您可能还需要指定其他设置$configArgs
才能使该功能正常工作(最近没有测试过)。另请参阅http://php.net/manual/en/function.openssl-csr-new.php以了解支持的进一步配置参数的说明。
回答by Simon
You check the OPENSSL_CONF variable in xampp/apache/conf/extra/http-xampp.conf
您检查 xampp/apache/conf/extra/http-xampp.conf 中的 OPENSSL_CONF 变量
Then start apache using the xampp/apache_start.bat NOT THE XAMPP CONTROL PANEL (its strange that when started from the control panel it doesn't work [maybe a current directory problem])
然后使用 xampp/apache_start.bat 而不是 XAMPP 控制面板启动 apache(奇怪的是,从控制面板启动时它不起作用 [可能是当前目录问题])
This is for XAMPP 1.7.4 on Win7 64bit
这适用于 Win7 64 位上的 XAMPP 1.7.4