PHP OpenSSL - openssl_private_encrypt crashes webpage - php

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.

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.

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.

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?

Related

Running Laravel on local machine

I am trying to run a laravel project in my local machine. It starts normally on http://127.0.0.1:8000 but when I try to open the url in the browser the port changes to 8001 and the new url is http://127.0.0.1:8001. When I try to open this in the browser, again the port changes to 8002.
Image showing the issue
composer.json
My PHP version is 7.4.1. If anyone else faced this issue earlier or knows how to fix this issue, please help in fixing this issue.
Thank you.
Update 1:
Noticed something. Whenever database related code is executed, this issue is popping up. For example, when I try to execute the following code shown in the image, it runs smoothly and I can see the output in the browser. Case when the code runs smoothly
But when I change the code to the following, the issue shows up.
Case when the issue shows up. This is not any database heavy query but why this issue? Any leads would be very helpful.
Update 2:
Found nothing in laravel logs but found the following in the apache error log which is given below:
[Thu Jun 09 21:37:24.988703 2022] [mpm_winnt:crit] [pid 2660:tid 704] AH02538: Child: Parent process exited abruptly. Child process is ending
[Thu Jun 09 21:37:27.399609 2022] [core:warn] [pid 8084:tid 576] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Thu Jun 09 21:37:27.446479 2022] [mpm_winnt:notice] [pid 8084:tid 576] AH00455: Apache/2.4.41 (Win64) OpenSSL/1.1.1c PHP/7.4.1 configured -- resuming normal operations
[Thu Jun 09 21:37:27.446479 2022] [mpm_winnt:notice] [pid 8084:tid 576] AH00456: Apache Lounge VC15 Server built: Aug 11 2019 12:20:04
[Thu Jun 09 21:37:27.446479 2022] [core:notice] [pid 8084:tid 576] AH00094: Command line: 'c:\xampp\apache\bin\httpd.exe -d C:/xampp/apache'
[Thu Jun 09 21:37:27.446479 2022] [mpm_winnt:notice] [pid 8084:tid 576] AH00418: Parent: Created child process 10064
[Thu Jun 09 21:37:28.196453 2022] [mpm_winnt:notice] [pid 10064:tid 664] AH00354: Child: Starting 150 worker threads.
Try this parameter I think help you
php artisan serve --port=8080
This highly, might be a problem to the code, you've write-ed, not a Laravel problem. I've faced issues like this before for a long time ago, so you might check :
The code is processing in blade or controller.
Or it might be a memory issues related to PC (might not be, related to this issue, but i had a lots of memory issues back then when i had low-end PC and all these issues was happening.)
As I said, my first guess is the code, so you might need to share the code find out, what is happening.
Also conflicts in reserved ports will be avoided anyway, for example if you set your local environment server to something else(8080), same issue will happen again.
And sometime if you close your terminal without closing local environment, new php artisan serve will run the local environment anyway, for example, my terminal/IDE was closed but application was serving, and doing php artisan serve not forced me to close and run a new local environment like yours, it was trying to serve again, but old one was doing conflicts.
So as I said again, it might be a code issue.
Double check your code or share it to find the issue.

Unable to codesign PHP v7.4 with Apache on Big Sur

Big Sur Macbook — I installed PHP v7.4 using Homebrew, and Apache gave an error message that PHP was not signed. So I followed the steps in this article explaining how to create a certificate authority and code signing certificate in Keychain Access. It worked once, but now I keep getting this error:
[Mon Oct 25 23:37:21.877634 2021] [so:error] [pid 3007] /usr/bin/codesign failed; unable to obtain code signature for module
[Mon Oct 25 23:37:21.877668 2021] [so:warn] [pid 3007] AH06663: Unable to find code signature authority on module at /usr/local/opt/php#7.4/lib/httpd/modules/libphp7.so that matches authority name "My Name" configured on LoadModule directive. Proceeding with loading process, but this will be an error condition in a future version of macOS.
Failed loading /usr/local/opt/php#7.4/lib/php/20190902/opcache.so: dlopen(/usr/local/opt/php#7.4/lib/php/20190902/opcache.so, 9): no suitable image found. Did find:
/usr/local/opt/php#7.4/lib/php/20190902/opcache.so: code signature in (/usr/local/opt/php#7.4/lib/php/20190902/opcache.so) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
/usr/local/opt/php#7.4/lib/php/20190902/opcache.so: stat() failed with errno=22
[Mon Oct 25 23:37:21.925733 2021] [mpm_prefork:notice] [pid 3007] AH00163: Apache/2.4.48 (Unix) PHP/7.4.25 configured -- resuming normal operations
[Mon Oct 25 23:37:21.925784 2021] [core:notice] [pid 3007] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Mon Oct 25 23:45:01.160927 2021] [mpm_prefork:notice] [pid 3007] AH00169: caught SIGTERM, shutting down
Also, VS Code has started to demand all of my CPU power, but only when I'm looking at the root folder. If I start at the /etc or /var folder it's fine. What's going on? How can I troubleshoot and fix this?
You may need to codesign again like so:
codesign -s "My Name" --keychain ~/Library/Keychains/login.keychain-db /usr/local/opt/php#7.4/lib/httpd/modules/libphp7.so
And you may have to trust your own previous created "My Name" certificate again.
Sounds like an "after update" issue.
Please also refer to this answer i recently made around the same topic.

Softaculous Ampps 3.8 Apache not starting if i change PHP version to 7.1

I have a recent problem in Ampps Software on Windows 10, Apache stopping automatically if PHP version is 7.1 but if I change back PHP Version to 5.6 it's working fine
and here's the error log for Apache
<pre>
[Mon Oct 22 10:28:12.413768 2018] [mpm_winnt:notice] [pid 12484:tid 684] AH00455: Apache/2.4.27 (Win32) OpenSSL/1.1.0f PHP/5.6.31 configured -- resuming normal operations
[Mon Oct 22 10:28:12.413768 2018] [mpm_winnt:notice] [pid 12484:tid 684] AH00456: Apache Lounge VC15 Server built: Jul 7 2017 11:43:51
[Mon Oct 22 10:28:12.413768 2018] [core:notice] [pid 12484:tid 684] AH00094: Command line: 'apache\\bin\\httpd.exe -d D:/Ampps/apache'
[Mon Oct 22 10:28:12.417758 2018] [mpm_winnt:notice] [pid 12484:tid 684] AH00418: Parent: Created child process 5924
[Mon Oct 22 10:28:13.307885 2018] [mpm_winnt:notice] [pid 5924:tid 740] AH00354: Child: Starting 64 worker threads.
[Mon Oct 22 10:28:45.068164 2018] [mpm_winnt:notice] [pid 9816:tid 700] AH00455: Apache/2.4.27 (Win32) OpenSSL/1.1.0f PHP/7.1.8 configured -- resuming normal operations
[Mon Oct 22 10:28:45.068164 2018] [mpm_winnt:notice] [pid 9816:tid 700] AH00456: Apache Lounge VC15 Server built: Jul 7 2017 11:43:51
[Mon Oct 22 10:28:45.068164 2018] [core:notice] [pid 9816:tid 700] AH00094: Command line: 'apache\\bin\\httpd.exe -d D:/Ampps/apache'
[Mon Oct 22 10:28:45.070158 2018] [mpm_winnt:notice] [pid 9816:tid 700] AH00418: Parent: Created child process 15180
[Mon Oct 22 10:28:47.563384 2018] [mpm_winnt:crit] [pid 9816:tid 700] AH00419: master_main: create child process failed. Exiting.
</pre>
I didn't change anything or install anything new, and I reinstalled it many times and tried XAMPP it's working fine
Thank you.
Its solved by disabling Ioncube loader extension for me, Thanks for all replies
Try changing the php version used by AMPPS by following their guide here ->
http://www.ampps.com/wiki/How_to_change_php_version
In the AMPPS control panel, select options and then select change php version. The changed version should now be displayed in the control panel.
Try run httpd.exe with as administrator and it worked.
C:\Program Files (x86)\Ampps\apache\bin
I know this is 4 months old, but I have had significant problems with PHP on windows and today I got this problem fixed.
AMPPS - It won’t run PHP 7.1 with out changing the executables to run as administrator mode. Apache will terminate without an error. I believe this is because even if AMPPS is running in admin priviledges these are not granted to the php.exe when it is run. Go to the file location of php.exe, right click and click on properties, click the compatibility tab and select the check box for ‘run as administrator’. Do the same for the httpd.exe under apache->bin->httpd.exe. (Not sure if the httpd priviledge change matters but I did it and it worked.)
Run AMPPS and hopefully like me, your php/apache problems are gone.
i solved mine following steps below:
i switched PHP version to 5.6 which everything works normally,
then went to this URL:
http://localhost/ampps/index.php?
there i found some updates available
notification on top of the page below url bar on the page
if you see updates available for your php 7.0 7.1 ...
90% you will resolve this issue like mine
i tried update all available updates
then restart the ampps app
now working with PHP 7.1 great.
i hope it works for you as well.
A bit late but since i've been using Ampps for 5 years , i provide similar solutions for my common errors maybe someone find it useful .
If you changed Document Root path in "httpd.conf" , make sure that folder still exists.
If you see the logs about InnoDB files, follow the path and delete that dump files and logs.
If you got this error "master_main: create child process failed" in log files :
Change PHP version to 7.1 and Try this:
Open AMPPS panel --> PHP --> Configuration.
Search for the following line and comment it by adding ';' at the beginning of the line: zend_extension="{$path}\php-7.1\ioncube_loader_win_7.1.dll"

Adding the ZeroMQ PHP extension to XAMPP on Windows 10 and PHP7

I am having issues adding the ZeroMQ PHP extension to XAMPP.
Setup: Windows 10, PHP7, XAMPP (7.0.9)
Steps I already took:
Added PHP (D:\xampp7\php) and PHP extensions (D:\xampp7\php\ext) directories to system variable (PATH)
Followed the instructions on zeromq.org. I downloaded x86ts version from the pecl repository as the listed snapshot link (http://snapshot.zero.mq/) was down.
Copied libzmq.dll into PHP directory and php_zmq.dll into the PHP extension directory
Updated php.ini (D:\xampp7\php\php.ini) by adding extension=php_zmq.dll and checked the extensions directory which is extension_dir="D:\xampp7\php\ext"
Restarted XAMPP via the control panel.
The Apache error log shows the following:
[Sat Nov 26 18:30:27.461679 2016] [ssl:warn] [pid 15280:tid 588] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sat Nov 26 18:30:27.546320 2016] [core:warn] [pid 15280:tid 588] AH00098: pid file D:/xampp7/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Sat Nov 26 18:30:27.630955 2016] [ssl:warn] [pid 15280:tid 588] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
PHP Warning: PHP Startup: Unable to load dynamic library 'D:\\xampp7\\php\\ext\\php_zmq.dll' - Das angegebene Modul wurde nicht gefunden.\r\n in Unknown on line 0
[Sat Nov 26 18:30:27.662208 2016] [mpm_winnt:notice] [pid 15280:tid 588] AH00455: Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/7.0.9 configured -- resuming normal operations
[Sat Nov 26 18:30:27.662208 2016] [mpm_winnt:notice] [pid 15280:tid 588] AH00456: Apache Lounge VC14 Server built: Jul 1 2016 11:09:37
[Sat Nov 26 18:30:27.662208 2016] [core:notice] [pid 15280:tid 588] AH00094: Command line: 'd:\\xampp7\\apache\\bin\\httpd.exe -d D:/xampp7/apache'
[Sat Nov 26 18:30:27.662208 2016] [mpm_winnt:notice] [pid 15280:tid 588] AH00418: Parent: Created child process 964
[Sat Nov 26 18:30:28.363210 2016] [ssl:warn] [pid 964:tid 616] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
Update:
It looks like the module cannot be found, but if I add the x64 Version the Apache error log indicates that the module is not a not a valid Win32 application.
PHP Warning: PHP Startup: Unable to load dynamic library 'D:\\xampp7\\php\\ext\\php_zmq.dll' - %1 ist keine zul\xef\xbf\xbdssige Win32-Anwendung.\r\n in Unknown on line 0
Solution:
Adding LoadFile "D:/xampp7/php/libzmq.dll"to httpd.conf fixed my issue.
these steps worked for me (php 7.1.7 - xampp - window 10 x64)
Step 1
download x86 dll files from this site
Step 2
copy php_zmq.dll to C:\xampp\php\ext
Step 3
copy libsodium.dll and libzmq.dll to C:\xampp\php
Step 4
add extension=php_zmq.dll to php.ini file
Step 5
restart apache
I know this is an old question although I just spent 2 days trying to get ZeroMQ to load properly. If anyone still cant get it to work after following all the basic instructions, I have 2 more steps you can look into.
Got it working with php 7.3.12, Win10 x64
1st. Make sure you edit all php.ini files.
If you use wamp server, Apache will have it's own php.ini that is opened up when you click on the wamp icon in the bottom right of windows and go to php->php.ini. Then manually add the same extension=php_zmq.dll there as well as your php.ini under D:\xampp7\php\php.ini. To be honest, I'm not 100% sure that this is necessary but including it on both cant hurt.
2nd. Run deplister.exe on libzmq.dll
This is what got it working for me. Any php download from windows.php.net should have deplister.exe (it is included in wamp php versions too). Go to your php version library on your wamp server where libzmq.dll and deplister.exe are located. Then open up cmd and run the line: deplister php_zmq.dll This will show you a list of the dependencies that php_zmq.dll requires to run. You may notice that it requires a VERY specific version of libzmq.dll so go and rename your dll file to the requested file name. Then run php -m to see if zmq is displayed on the list of modules. If so, you should be able to run commands like composer update to get the required library versions imported into your project without error!

XAMPP causing 'The connection was reset' error in Firefox

I'm experiencing problems when running a specific PHP file; in the latest Firefox it keeps giving the error 'The connection was reset' (I've tried running the PHP file in a different browser - the latest Internet Explorer but get the same problem).
I've also tried completely uninstalling both XAMPP and Firefox (default browser) - then reinstalling them.
I have even tried clearing the cache in Firefox and also ran CCleaner.
I'm not sure what is causing this problem as when I run the exact PHP file on another machine (on Windows 7 - with XAMPP & latest Firefox) it works perfectly fine and it is not like the PHP file is fairly complex/resource intensive (it does not even call/use MySQL!)? :S
I have tried integrating some debug/error reporting code within the PHP file - but that does not produce/do anything, but I've noticed whenever the PHP file is ran; apache does create/update an 'error.log' file within the 'XAMPP/apache/logs' folder with the following errors:
[Tue May 28 07:31:18.158004 2013] [ssl:warn] [pid 2404:tid 328] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue May 28 07:31:18.283009 2013] [mpm_winnt:notice] [pid 2404:tid 328] AH00455: Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7 configured -- resuming normal operations
[Tue May 28 07:31:18.283009 2013] [mpm_winnt:notice] [pid 2404:tid 328] AH00456: Server built: Aug 18 2012 12:41:37
[Tue May 28 07:31:18.283009 2013] [core:notice] [pid 2404:tid 328] AH00094: Command line: 'c:\\users\\admin\\xampp\\apache\\bin\\httpd.exe -d C:/Users/Admin/XAMPP/apache'
[Tue May 28 07:31:18.283009 2013] [mpm_winnt:notice] [pid 2404:tid 328] AH00418: Parent: Created child process 4112
PS-1: I noticed it is referring to SSL within the above log - I'm not using SSL?.
PS-2: The XAMPP settings are exactly the same since the install (like I have not modified/updated php.ini or have added anything that does within the .htaccess file).
OS: Windows 8 (64 bit)
XAMPP: 1.8.1 (installed relatively to user 'Admin' => 'C:/Users/Admin/XAMPP')
Browsers: Latest - Firefox (default) and Internet Explorer, both have NO third-party extensions/add-ons installed/enabled
Security programs: Avira Free Antivirus, Malwarebytes Anti-Malware (PRO) and KeyScrambler (Personal)
I had what might be a similar problem a few years back, and, if I recall correctly, it was caused by using Notepad to write the script. Upon switching to another text editor the problem was fixed. As I recall, there were hidden characters inserted by Notepad (or whatever it was that I had used).

Categories