XAMPP And file_get_contents("https://...") - php

I've tried running the next code on xampp :
$url2="https://....";
$content=file_get_contents($url2);
and that's the error I've got :
Warning: file_get_contents() [function.file-get-contents]: Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in C:\xampp\htdocs\whoTalk\sys\user.php on line 38
What do I have to do in order to be able to get contents of a url which a https:// wrapper?
Thanks in advance

In your php.ini search for the following:
extension=php_openssl.dll
If it is there and commented, uncomment it. If it is not there, add it :-)

in WAMP I added
allow_url_include = On
extension=php_openssl.dll
extension=php_curl.dll
to all 3 php.ini files I could find, namely
\wamp\bin\php\php5.4.12\php.ini
\wamp\bin\php\php5.4.12\phpForApache.ini
\wamp\bin\apache\Apache2.4.4\bin\php.ini
I don't know which specific settings in which .ini file is actually needed, but https is accepted now....

You would need to have the OpenSSL extension for PHP enabled in XAMPP to grab anything from a secure server.

Related

Error in PHP on https wrapper

I am getting the following error and I am hosting the a local server using WAMP and using version 5.6.19 of PHP
Warning: file_get_contents(): Unable to find the wrapper "https" - did
you forget to enable it when you configured PHP?
You need to enable php-openssl in your WAMP.
For this, click on the WAMP icon in your systemtray. Click on PHP. Then hover the PHP Extensions. Then click on the php_openssl
I think what you can try is to:
Install php5-openssl
Restart Apache afterwards.
It will likely to solve that problem.
And there's also another possible solution:
You can find the "php.ini" file, and open it, you will find the line: extension=php_openssl.dll And is there a semicolon at beginning? If yes, simply delete it and it will work.
If that doesn't work or you have further issues, comment me and I will help you! :)

Laravel 5 Socialite - cURL error 77: error setting certificate verify locations

I am using socialite in Laravel 5 to setup facebook login. I followed the instructions carefully until I got stuck with the following error
cURL error 60: SSL certificate problem: unable to get local issuer certificate
so I found the this answer to fix it which indeed passed but then I got this error
cURL error 77: error setting certificate verify locations:
CAfile: /Applications/XAMPP/xamppfiles/cacert.pem
CApath: none
Any ideas what's the cause of this error?! and how to fix it?!
I got stuck on this problem as well. It turned out that I had the path to my certificate set incorrectly in my php.ini file. Forgot the .txt extension.
What I had:
curl.cainfo = "C:\xampp\php\cacert.pem"
What I changed it to:
curl.cainfo = "C:\xampp\php\cacert.pem.txt"
Hope this helps.
Add cacert.pem file from https://curl.haxx.se/ca/cacert.pem in
c:\xampp\php\cacert.pem
Change setting in php.ini file:
curl.cainfo = "C:\xampp\php\cacert.pem
My error is:
cURL error 77: error setting certificate verify locations: CAfile:
C:\xampp\apache\bin\curl-ca-bundle.crt CApath: none (see
http://curl.haxx.se/libcurl/c/libcurl-errors.html)
This works well for me:
Download the certificate from: https://curl.haxx.se/ca/cacert.pem
Rename the cacert.pem file into curl-ca-bundle.crt
Copy the file into path/to/xampp/apache/bin
Restart apache
I experienced some issues following instructions in regards to error 77.
On Windows 7, depending on your security settings - the file downloaded may be blocked. See screenshot:
Once I unblocked the file and ensured proper user access rights, I also had to put the file in the following location:
C:\xampp\apache\bin\cacert.pem.txt
In addition to changing php.ini per the other posts on this issue.
curl.cainfo="C:\xampp\php\cacert.pem.txt"
After completing the above steps, restarting Apache via the XAMPP Control Panel, the error was resolved.
Save this certificate (https://curl.haxx.se/ca/cacert.pem) as cacert.pem.txt in C:\xampp\php
Add to php.ini:
curl.cainfo = "C:\xampp\php\cacert.pem.txt"
Don't forget to restart XAMPP (it won't work until it restarts)
Then it works fine!
Download from (https://curl.haxx.se/ca/cacert.pem)
Change the name 'cacert.pem' to 'curl-ca-bundle.crt' (after that, move it to the path 'C:\xampp\apache\bin')
In 'php.ini', remove ';' in the following line:
curl.cainfo="C:\xampp\apache\bin\curl-ca-bundle.crt"
That works for me.
Checkout double quote on php.ini file:
if you copied and past from the Web maybe you got wrong double quote:
”C:\xampp\php\cacert.pem.txt”
instead of
"C:\xampp\php\cacert.pem.txt"
In your php.ini file, you should also update your
;openssl.cafile
with the same cacert.pem link you used in updating your
;curl.cainfo
Have a look at mine before and after
;curl.cainfo =
;openssl.cafile=
to
curl.cainfo ="C:\php-7.4.11\extras\ssl\cacert.pem"
openssl.cafile="C:\php-7.4.11\extras\ssl\cacert.pem"
this fixes the cURL 60 error
curl.cainfo ="C:\php-7.4.11\extras\ssl\cacert.pem"
while
openssl.cafile="C:\php-7.4.11\extras\ssl\cacert.pem"
fixes the cURL 77 error.
Have fun!
NB: Do not forget to restart your server before trying it out.
For those who wish to find their php.ini file, use this command after you cd into your application
php -i | grep 'Configuration File'
You need to replace the existing certificate with the other one here. After that:
Extract and add it to xampp\php\ext
Open xampp\php\php.ini
Add this line curl.cainfo='location from the first step' to the end of the file.
Restart and it should be working now.
This is the source link.
For windows
I had same problem after i updated php on window 2008. Suddenly all my php codes stopped working. What i did, i opned php.ini then i found a line
;curl.cainfo =
and i changed to
curl.cainfo = "C:\Program Files (x86)\PHP\v7.0\cacert.pem" (remember to remove ; before curl.cainfo)
and everything went to normal. What you need is to download a cert file cert.pem and place it anywhere on your server and change the line as i did in php.ini
This same problem with me in php version 8.0.3 on windows :
Solution was I had to uncomment and set openssl.capath=path of certs in php.ini file.
I already set openssl.cafile so it was not throwing error for that but oepnssl.capath was not set sot error was there.
openssl.cafile="C:\Users\Akta\Softwares\php-8.0.3-nts-Win32-vs16-x64\extras\ssl\demoCA\cacert.pem"
openssl.capath="C:\Users\Akta\Softwares\php-8.0.3-nts-Win32-vs16-x64\extras\ssl\demoCA\certs"
I read every thread I could find and this one provided the missing piece.
Background: I encountered this issue will trying to get Drupal 8 to check for available updates on a fresh development environment (wamp based).
Get a copy of the Certificate data from Mozilla, it can be found here:
https://curl.haxx.se/ca/cacert.pem
If you want to know more about what this is read this: https://serverfault.com/questions/241046/what-is-the-cacert-pem-and-for-what-to-use-that
Save the file as "cacert.pem.txt" not as "cacert.pem" This was the missing piece, thanks LyleK!. I have no clue why but you must have the .txt extension on the end or it does not work.
Explicitly add the path to the location of the "cacert.pem.txt" file to your php.ini
Example:
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo = "C:\wamp\custom\cacert.pem.txt"
If you are using a wamp stack restart it. You should be good to go.
First, you need to download your "curl.cainfo" file then you need to locate it to C:\xampp\php\cacert.pem.txt.
Second, you need to open your php.ini file in Xampp and copy this
=>
curl.cainfo = C:\xampp\php\cacert.pem.txt anywhere you want.
Third please restart your Apache Server refresh your localhost page and that should work fine.
If anyone is running Windows with Plesk and they get this error.
You must ensure that the curl.cainfo path is inside the Plesk PHP directory otherwise you will get the error above even with the fix.
curl.cainfo = "C:\Program Files (x86)\Parallels\Plesk\Additional\PleskPHP55\extras\ssl\cacert.pem.txt"
Fixed for me. Hope this helps someone, someday, somewhere.
I've tried #mahesh-singh-chouhan, #omarsafwany, #LyleK solutions. but get same error repeatedly.
After that, I update php.ini file without double quotes & with .pem extension & I'm succeed to get desired result with below code.
curl.cainfo=E:\Xampp-5.6.3\php\ext\cacert.pem
I've also attached Screenshot.
Please first try above users suggestions, If failed also use this.
Thanks for solutions It creates way for me
#mahesh-singh-chouhan, #omarsafwany, #LyleK
I had the same issue and i tried every solution mentioned here and on other posts but none of them worked. I tried
1) Setting proper file rights ( didn't work )
2) Changing file extension ( didn't work)
then i moved the cacert.pem file inside php/ directory in xampp and restarted it, it worked. Hope it helps someone.
this worked for me
curl.cainfo = "C:\xampp\php\cacert.pem.txt"
hope it helps some one :)
It seems you forgot to add quote for the file path. I was got the same error (77), that was because i forgot to add quotes. I solved the problem by adding that. ex: "C:\AppServ\php\cacert.pem"
you did not read the error carefully, now read it carefully
cURL error 77: error setting certificate verify locations: CAfile: D:\XAMPP\apache\bin\curl-ca-bundle.crt CApath: none (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
it means you are missing a file called curl-ca-bundle.crt to verify certificate locations,
so you just need to put this(curl-ca-bundle.crt) file into your XAMPP\apache\bin\ folder
and everything is fine error 77 has gone.
curl-ca-bundle.crt, to download the file you can use this link https://github.com/nirmalkumar98/nk
i had this problem in windows 2012
i had a virtual dedicated server that host for laravel
then i had this error and
download that file from here
put in my extras folder in php 7.2
in my php.ini file find this line
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo = extras/ssl/cacert.pem
i paste my download file into php file sth like this:
curl.cainfo = "C:\Program Files (x86)\PHP\v7.2\extras\ssl\cacert.pem"
then save php.ini
then restart my iis or just website
in my case i just restart my website
For solve this error use this code :
$client = new Client(['verify' => false ]);
And use this $client like this in your code:
$headers = [
'Authorization' => 'Bearer ' . $token,
'Accept' => 'application/json',
RequestOptions::BODY => ' any code for your body ',
];
$response = $client->request('POST', 'bar', [
'headers' => $headers
]);
$response = $response->getBody()->getContents();
return $response;
ULTIMATE SOLUTION THAT WORKS 2022, 2023, 2024
Download from [(https://curl.haxx.se/ca/cacert.pem)][1]
Download the 'cacert.pem' twice
Change the name of the second downloaded 'cacert.pem' to 'cacert.crt'
Place both files in C:/wamp64/bin/php/php7.4.26/extras/ssl/
In your php.ini file from the wamp sever,
Uncomment ;curl.cainfo & ;openssl.cafile, be removing the semicolon before it.
Make changes as shown below:
curl.cainfo ="C:/wamp64/bin/php/php7.4.26/extras/ssl/cacert.perm"
openssl.cafile="C:/wamp64/bin/php/php7.4.26/extras/ssl/cacert.crt"
Restart wamp
It works like merlin magic (-_-)
i had the same problem. you have to open the file .pem or pem.txt with a simple editor (bloc-note) and past the (https://curl.haxx.se/ca/cacert.pem) in your file. you have to reload apache.
If it is related to git:
git config --global http.sslverify "false"
will solve the problem.

Call to undefined function curl_init() in codeiginter

I am receiving this error when I try to access my newsletter plugin, I have uncomment the curl extension in both php\php.ini and apache\php.ini, and also in configuration file of php. Even I restarted my server after changes but still I am getting error. How can I solve this issue ??
I have tried these extensions (extesnions link here) according to my php version and it worked!
Cheers
Start the Curl extension of PHP directly by changing PHP.ini file or by clicking wamp and then scroll to PHP->extensions

Why am I getting an SSL error in PHP even though I enabled the php_openssl.ext?

I am running my PHP code off of XAMPP. I am trying to connect to a WSDL form with a SoapClient object. The error says I need to enable the php_openssl in my php.ini documents but I already have and it is still not working. Here is the exact error: Warning: SoapClient::__doRequest(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in C:\xampp\htdocs\series\UI\SOAP\test.php on line 15
SSL support is not available in this build Is there anything else I need to enable on my php.ini?
Have you checked if the "extension_dir" directive is set to the right folder? Make sure to use an absolute path to that folder.

wamp cannot load mysqli extension

WAMP installed fine, no problems, BUT...
When going to phpMyAdmin, I get the error from phpMyAdmin as follows:
Cannot load mysqli extension. Please check your PHP configuration
Also, phpMyAdmin documentation explains this error message as follows:
To connect to a MySQL server, PHP needs a set of MySQL functions
called "MySQL extension". This extension may be part of the PHP
distribution (compiled-in), otherwise it needs to be loaded
dynamically. Its name is probably mysql.so or php_mysql.dll.
phpMyAdmin tried to load the extension but failed. Usually, the
problem is solved by installing a software package called "PHP-MySQL"
or something similar.
Finally, the apache_error.log file has the following PHP warnings (see the mySQL warning):
PHP Warning: Zend Optimizer does not support this version of PHP - please upgrade to the latest version of Zend Optimizer in Unknown on line 0
PHP Warning: Zend Platform does not support this version of PHP - please upgrade to the latest version of Zend Platform in Unknown on line 0
PHP Warning: Zend Debug Server does not support this version of PHP - please upgrade to the latest version of Zend Debug Server in Unknown on line 0
PHP Warning: gd wrapper does not support this version of PHP - please upgrade to the latest version of gd wrapper in Unknown on line 0
PHP Warning: java wrapper does not support this version of PHP - please upgrade to the latest version of java wrapper in Unknown on line 0
PHP Warning: mysql wrapper does not support this version of PHP - please upgrade to the latest version of mysql wrapper in Unknown on line 0
So, for some reason PHP is not recognizing the mysql extension.
Anyone know why? Any solution or workaround?
I deleted the PHP in program files ad everything started working , the problem that there two installations of pHp
I tried many solutions, and none worked for me. I tried the following solutions:
Restart wampserver
Reinstall wampserver
restart machine
and all other solutions mentioned in this question.
However, none of these worked. Then I found that my PHPMyAdmin was not working in chrome and was working in firefox. So I tried clearing cache, restarting browser etc, but still it would not work.
Then I deleted all the files from C:\wamp\tmp and then tried again, and it works. I am not sure why it works, but here is what I think. The session was cached and not getting cleared. So as soon as I deleted all files in this directory all the sessions were deleted and hence it worked fine.
First, make sure that the php.ini file is loading the mysqli extension.
If you are using WAMPServer, click on the icon in the system tray, go to PHP -> PHP Extensions and make sure it is checked. If not, go into the php.ini file and make sure that the line: extension=php_mysqli.dll is uncommented (eg, remove the ; if it exists). If that line does not exist, add it.
If this still does not work, double check that the right php.ini file is being loaded.
To do so, view your phpinfo() (Here for WAMPServer). Scroll down to the Loaded Configuration File row and see which php.ini is being loaded.Make sure it is the right file. If you're using WAMPServer, it should be(WAMP INSTALL FOLDER)\bin\apache\Apache2.2.11\bin\php.ini. By default, it isC:\wamp\bin\apache\Apache2.2.11\bin\php.ini`.
If a different php.ini file is being loaded, just rename it to something else so that PHP will try and find the file somewhere else. There should be a way to specify which on eyou want to use, but I forget exactly how to do that...
If this still doesn't work... Try messing around with phpMyAdmin's settings, or using another answer, but I'm afraid I can't help beyond this.
I was running WAMP with two PHP versions 1) 5.2.9 and 2) 5.2.13.
As per site requirement i needed to change PHP version to 5.2.9 from 5.2.13. after swapping PHP version, error was "mysqli extension is missing". after debugging long time i get to know it was due to wrong "extension_dir" path in php.ini file.
So i changed its value:
Old: "extension_dir" c:/wamp/bin/php/php5.2.13/ext/
New: "extension_dir" c:/wamp/bin/php/php5.2.9/ext/
Restarted All services in wamp server, then it's fixed.
I had the same problem. I had WAMP server installed. All was working fine. Then one day I restarted my computer and it just stopped working! I tried desperately going through all help posts and doing them but nothing worked.
What they usually suggest you do is, first go to your php.ini file and make sure your 'extension_dir' is properly set. Then to make sure these two lines are not commented (remove the ; infront):
extension=php_mysql.dll
extension=php_mysqli.dll
Then some suggested that I download fresh copies of these two files but none worked. I also tried uninstalling everything (php/mysql/apache) and reinstalled fresh copies of WAMP server several times but with no luck.
Finally I managed to find an alternative solution. I switched to 'easyphp' (http://www.easyphp.org/). This is something very similar to WAMP. First I made backups of my sql databases so I can reload them on the new installation.
Then I installed 'easyphp' and everything seems to work fine. I reloaded my sql databases from my backup and now things are back to normal.
I hope someone suffering from a similar prob. will find this useful. If someone has really found a fix to make WAMP server work. Pls do be kind enough to post it here so many will benefit.
in wampserver go to php.ini. open the file and uncomment extension=msql.dll by removing semicolon(;) for respective operating sytem.
Just add in your php.ini:
[PHP_MCRYPT]
extension=php_mcrypt.dll
[PHP_MYSQL]
extension=php_mysql.dll
[PHP_MYSQLI]
extension=php_mysqli.dll
Also setup the mysql password:
SET PASSWORD FOR root#localhost=PASSWORD('your_password');
And the phpmyadmin mysql password in config.inc.php:
$cfg['Servers'][$i]['password'] = 'your_password';
Had the same problem, with wamp. Try to exchange your current version of php.ini with a backup. There is one in: wamp\bin\php\php5.3.0phpForApache.txt. Worked for me.
Just wanted to chime in on this one. Using Wamp Server 2.0, and using Zend Studio with Zend debugger for development.
I wasn't able as of yet (will get back to it at some point) to get the zend debugger working with php 5.3. So in wamp I loaded an earlier php version, 5.2.11. I was getting the same error when acessing php my admin.
What I had to do was change the php.ini file value for "extension_dir" to c:/wamp/bin/php/php5.2.11/ext/ to match the version of php I was using. After that it was all good.
I had this problem and spent 2 hours trying all the solutions online, none worked.
Tried this, and it woked:
Change
mysql.default_host =
to
mysql.default_host = localhost
and restart WAMP. pay attention if you are using mysqli or not.
I had the same error. When I increased the script memory size and enabled E_ALL then restarted the server, I got that error in phpmyadmin. All I had to do to fix it was restart my computer!
I got this problem for a long time. Tried all I've read on forums and this finally worked for me:
Open your php.ini (I assume you've got the good one that is loaded...) and find this line
mysqli.default_port = 3306
change for
mysqli.default_port = 80
Restart all services
Go to localhost/phpmyadmin -> won't work
Reopen the php.ini file and retype this
mysqli.default_port = 3306
Restart all services
Worked for me.
For me worked this, after searching all logs/internet/every non-normal things.
You have to register dl by:
Through application:
WAMP -> PHP settings -> enable dl
or
# php.ini #
; Whether or not to enable the dl() function. The dl() function does NOT work
; properly in multithreaded servers, such as IIS or Zeus, and is automatically
; disabled on them.
; http://php.net/enable-dl
enable_dl = On
I have just installed WampServer, and faced same problem. I have found solution, that works for me, it is ridiculously simple.
Disable PHP extension php_mysqli.
Restart WampServer, visit local phpmyadmin.
Enable php_mysqli back.
Repeat step 2.
After few page refreshes, remaining errors plates (about MySQL and sqli) had gone.
i tried hard by
installing the wamp again and again,
by checking the php.ini file,
by restarting the machine,
by replacing the index.php file,
but none works.
then i go to the wamp/temp and deleted all files and it works fine now.
I had path variable in windows set to some random version of php.
The fix was to update it and set it to the folder within my wampserver installation:
C:\wamp64\bin\php\php5.6.38
Then I realized this is wrong also for my specific case, and I should actually be running the script from within vagrant. Live and learn.
I had this issue because of a different reason:
Check the PHP Error Log(Get from the Wamp Tray -> PHP -> PHP Error Log.
I had a syntax error in the php.ini file while I was editing the file.
Check the log and clear the error. This will open your PhpMyAdmin properly.
Check your phpForApache.ini file's extensions. This file should be same as your php.ini file.

Categories