PHP OpenSSL - openssl_private_encrypt 使网页崩溃

问题描述 投票:0回答:4

这已在 bugs.php.net 上报告。如果我将 xampp/apache/bin 中的

libeay32.dll 和 ssleay32.dll
替换为
xampp/php/
中的相同文件,那么它可以工作,但我不能使用 SSL

我需要使用 SSL,有人能够解决这个问题吗?


我在 XAMPP(1.8.1) 上的 PHP(5.4.7) 中使用 OpenSSL 库进行加密、解密等。我还在本地主机上使用 SSL。

我可以使用

openssl_pkey_new()
方法创建私钥-公钥对并生成证书。

但是当我尝试访问我的根证书(使用上述函数创建)时,网页崩溃了

$root_private_key = openssl_get_privatekey(file_get_contents($path), $pass);
echo "KEY: " . $root_private_key; // KEY: Resource id #11
openssl_private_encrypt($plaintext, $encrypted_data, $root_private_key);

我什至尝试使用 phpseclib 库,但这也做了同样的事情。

我也尝试过设置

ini_set('max_execution_time', 0);


我检查了PHP日志,它是空的,并在Apache日志中发现了以下内容:

[mpm_winnt:notice] [pid 3312:tid 484] AH00428: Parent: child process exited with status 3221225477 -- Restarting.
[ssl:warn] [pid 3312:tid 484] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[mpm_winnt:notice] [pid 3312:tid 484] AH00455: Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7 configured -- resuming normal operations
[mpm_winnt:notice] [pid 3312:tid 484] AH00456: Server built: Aug 18 2012 12:41:37
[core:notice] [pid 3312:tid 484] AH00094: Command line: 'apache\\bin\\httpd.exe -d C:/xampp/apache'
[mpm_winnt:notice] [pid 3312:tid 484] AH00418: Parent: Created child process 1520
AH00548: NameVirtualHost has no effect and will be removed in the next release C:/xampp/apache/conf/extra/httpd-vhosts.conf:19
[ssl:warn] [pid 1520:tid 496] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[mpm_winnt:notice] [pid 1520:tid 496] AH00354: Child: Starting 150 worker threads.

我尝试过以下操作,但没有任何帮助:

PHP openssl_public_encrypt 导致页面超时/连接重置?

php/超时/与服务器的连接重置?

Apache 服务器(xampp)在使用 openssl 功能时崩溃

PHP 意外死掉且没有错误

我将不胜感激任何帮助/建议。

php openssl xampp public-key-encryption phpseclib
4个回答
2
投票

对于那些仍然遇到问题的人:

直到完整打包的 xampp 官方版本与下一版本的 apache 一起发布(应该修复此错误)之前,我已通过将我的 Apache 版本更改为此处找到的版本成功解决了此问题:http://www.apachelounge.com /download/ 这修复了错误,但仍然允许我使用 OpenSSL

本页上的第二个 Apache 2.2.4 下载是专门为修复此错误而构建的。对我来说这很简单:

  • 停止阿帕奇
  • xampp\apache
    重命名为
    xampp\apacheold
    以防万一它坏了。
  • 从下载的 zip 中将
    Apache24
    复制到
    xampp\Apache24
  • 将其重命名为
    apache
  • .bat
    文件从
    xampp\apacheold
    文件夹复制到新的
    xampp\apache
    文件夹中。
  • xampp\apache\conf
    文件夹替换为
    xampp\apacheold
  • 中的文件夹
  • 再次启动Apache

我希望这对某人有帮助。


1
投票

这已在 bugs.php.net 上报告。如果我将 xampp/apache/bin 中的以下文件替换为 xampp/php/ 中的相同文件,那么它就可以工作:

  • libeay32.dll
  • ssleay32.dll

但是,不能使用SSL,否则Apache在启动时会出错。


0
投票

phpseclib 使用 OpenSSL(如果可用)来生成 RSA 私钥。要禁用此行为,请在包含 Crypt/RSA.php 后执行此操作:

define('CRYPT_RSA_MODE', CRYPT_RSA_MODE_INTERNAL);

顺便说一句,您要生成的密钥有多大?


0
投票

从我这边我有:

  • Windows 11 上的 IIS
  • PHP 7.0
  • libeay32.dll 和 ssleay32.dll v1.0.2.8

我在模拟器中的 Visual Studio 中找到了 2 个 dll,版本为 1.0.2.19,我已经替换了它们并且它开始工作。这是因为 openssl_pkcs7_sign 函数一直崩溃。

希望这有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.