PHP OpenSSL - openssl_private_encrypt crashes webpage

穿精又带淫゛_ 提交于 2019-12-08 03:39:56

问题


This has been reported at bugs.php.net. If I replace libeay32.dll and ssleay32.dll in xampp/apache/bin with the same files in xampp/php/ then it works but I CANNOT use SSL

I need to use SSL, has anyone been able to resolve this?


I am using OpenSSL library in PHP(5.4.7) on XAMPP(1.8.1) for encryption, decryption, etc. I am also using SSL on localhost.

I am able to create the private-public key pair using openssl_pkey_new() method and generate the certificate as well.

But when I try to access my root certificate (create using the above function) the webpage crashes:

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

I even tried using phpseclib library but that also does the same thing.

I have also tried to set ini_set('max_execution_time', 0);


I checked PHP log and it is empty and found the following in Apache logs:

[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.

I have tried following but none of that helps:

PHP openssl_public_encrypt causing Page Timeout/Connection Reset?

php/timeout/connection to server reset?

Apache server (xampp) crashes when using openssl function

PHP dies unexpectedly without error

I would appreciate any help/suggestion.


回答1:


For those of you still having trouble:

Until a fully packaged official build of xampp is released with the next version of apache which should fix this bug, I have successfully fixed this issue by changing my version of Apache to one found here: http://www.apachelounge.com/download/ This fixes the bug but still allows me to use OpenSSL

The second Apache 2.2.4 download on this page was built specifically to fix this bug. For me it was easy as:

  • Stopping Apache
  • Renaming xampp\apache to xampp\apacheold just in case it broke.
  • Copied in the Apache24 to xampp\Apache24 from the downloaded zip
  • Renamed it to apache
  • Copied the .bat files from the xampp\apacheold folder into the new xampp\apache folder.
  • Replaced the xampp\apache\conf folder with the one from xampp\apacheold
  • Start Apache again

I Hope this helps somebody.




回答2:


This has been reported at bugs.php.net. If I replace the following files in xampp/apache/bin with the same files in xampp/php/ then it works:

  • libeay32.dll
  • ssleay32.dll

BUT, SSL cannot be used otherwise Apache gives error when starting up.




回答3:


phpseclib uses OpenSSL, if available, for RSA private key generation. To disable this behavior do this after Crypt/RSA.php has been included:

define('CRYPT_RSA_MODE', CRYPT_RSA_MODE_INTERNAL);

How big, btw, is the key you're trying to generate?



来源:https://stackoverflow.com/questions/16628102/php-openssl-openssl-private-encrypt-crashes-webpage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!