Unable to find the wrapper "https" - did you forget to enable it when you configured PHP?
Asked Answered
S

23

166

The problem is in the question. I've done a thorough investigation for solutions in regards to this and I know there are topics to this and I've followed them too and nothing has worked. That being said I'll list out exactly everything I've done so far. I am running PHP 5.2.14 with Zend Debugging on the latest Eclipse version on my Windows XP computer. I have a 1 GB of RAM. I have XAMPP running with Apache, MySQL, and FileZilla installed.

On XAMPP I've done the following (Apache was off during these changes): Clicked on Admin from the XAMPP Control Panel and went to https:// localhost/xampp/. From there I accepted the certs from this line on the welcome page:

For OpenSSL support please use the test certificate with https:// 127.0.0.1 or https:// localhost.

On that same section I checked phpinfo(). Under 'Environment', SERVER["HTTPS"] is on. Under 'Apache Environment', HTTPS is On. Under 'PHP Variables, _SERVER["HTTPS"] is On. Under 'Phar', OpenSSL support is disabled (install ext/openssl). I don't know how to enable the Phar one.

Now regarding the files themselves in C:\xampp, I went to the PHP folder. Under both production and development php.ini files (better safe than sorry), I have allow_url_fopen=On, allow_url_include=On, and I removed the semicolon, so that extension=php_openssl.dll is no longer commented out. I even confirmed that the .dll is in the ext folder of the PHP folder. Both libeay32.dll and ssleay32.dll are in the PHP and Apache folders. The Apache folder doesn't contain either productive or development php.ini files.

I've went to http://www.slproweb.com/products/Win32OpenSSL.html and installed Win32 OpenSSL v1.0.0d for safe measure.

Now the line of code in question in my retrieve_website.php looks like this:

$urlquery = "https://www.googleapis.com/customsearch/v1?key=".$appid."&cx=".$google_searchid."&q=".$query."&alt=atom&num=".$results;
$xmlresults = file_get_contents($urlquery);

I have two other websites that I query but they are served via HTTP and they work fine. I also have this line of code entered near the end of the script:

echo 'openssl: ',  extension_loaded  ('openssl') ? 'yes':'no', "\n";
echo 'http wrapper: ', in_array('http', $w) ? 'yes':'no', "\n";
echo 'https wrapper: ', in_array('https', $w) ? 'yes':'no', "\n";
echo 'wrappers: ', var_dump($w);

When I run it as a PHP Script on Eclipse, everything outputs perfectly fine the way I want along with these results:

openssl: yes
http wrapper: yes
https wrapper: yes
wrappers: array(10) {
  [0]=>
  string(5) "https"
  [1]=>
  string(4) "ftps"
  [2]=>
  string(3) "php"
  [3]=>
  string(4) "file"
  [4]=>
  string(4) "data"
  [5]=>
  string(4) "http"
  [6]=>
  string(3) "ftp"
  [7]=>
  string(13) "compress.zlib"
  [8]=>
  string(14) "compress.bzip2"
  [9]=>
  string(3) "zip"
}

Despite all these changes I've made (after I started up Apache), I still get the same errors the first time I access my PHP script in Eclipse and Firefox via http://localhost/tutorial/retrieve_website.php:

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\tutorial\retrieve_website.php on line 29

Warning: file_get_contents(https:// www.googleapis.com/customsearch/v1?key=removed API ID&cx=removed search ID&q=The+Devil+went+down+to+Georgia&alt=atom&num=5) [function.file-get-contents]: failed to open stream: No such file or directory in C:\xampp\htdocs\tutorial\retrieve_website.php on line 29

Warning: DOMDocument::loadXML() [domdocument.loadxml]: Empty string supplied as input in C:\xampp\htdocs\tutorial\retrieve_website.php on line 33

openssl: no http wrapper: yes https wrapper: no wrappers: array(10) { [0]=> string(3) "php" [1]=> string(4) "file" [2]=> string(4) "glob" [3]=> string(4) "data" [4]=> string(4) "http" [5]=> string(3) "ftp" [6]=> string(3) "zip" [7]=> string(13) "compress.zlib" [8]=> string(14) "compress.bzip2" [9]=> string(4) "phar" }

What is it that I have overlooked or failed to do? To my own knowledge, I've done everything that I've researched about concerning HTTPS and OpenSSL

Secor answered 26/3, 2011 at 18:14 Comment(0)
B
198

I solved it in XAMPP by uncommenting ;extension=php_openssl.dll in /apache/bin/php.ini despite phpinfo() telling me /php/php.ini was the loaded ini file.

EDIT: I guess Ezra answer is the best solution directly adding the extension line to the appropriate ini file.

Burton answered 19/8, 2011 at 15:7 Comment(4)
Are you sure that its /apache/bin/php.ini , I cannot find it in XAMPP Portable Light 1.8.1? However php/php.ini exists, but enabling ssl here does not help :(Bravery
this answer would then create another problem because openssl is now disabled and will throw an error if I get_file_contents a secured linkPhlegethon
For me it was xampp/php/php.ini :) thanks , PS: DONT FORGET TO RESTART APACHE AFTER SAVING CHANGESNicotine
There's no php_openssl.dll, it's just openssl.dll.Redoubtable
W
103

I had to add extension=php_openssl.dll to my php.ini file located in xampp/php/php.ini. Somehow it was not there, after adding it and restarting Apache everything was working fine.

Windward answered 20/3, 2012 at 16:46 Comment(2)
I had to add the line, as it was not in php.ini - but then did the trick - thanks!Insincerity
There's no php_openssl.dll, it's just openssl.dll.Redoubtable
Q
37

just add two lines in your php.ini file.

extension=php_openssl.dll
allow_url_include = On

its working for me.

Quar answered 25/9, 2012 at 16:20 Comment(5)
I'm using wamp and you need to edit the php.ini in the apache folder rather the the usual one in the PHP folder :OOxyacetylene
Thank you, it was the allow_url_include = On that solved it for me.Poise
Do not enable allow_url_include — this brings your server vulnerable.Amour
There's no php_openssl.dll, it's just openssl.dll.Redoubtable
in version 7 it is just opensslVenturous
F
18

Your Apache is probably not compiled with SSL support. Use cURL instead of file_get_contents anyway. Try this code, if it fails then I am right.

function curl_get_contents($url)
{
  $curl = curl_init($url);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
  $data = curl_exec($curl);
  curl_close($curl);
  return $data;
}
Fanchet answered 26/3, 2011 at 18:51 Comment(4)
ran that curl function you gave me and replaced $xmlresults = file_get_contents($urlquery); with $xmlresults = curl($urlquery);. PHP Script ran it just fine with the same results as file_get_contents(). Running it as PHP Web Page via localhost/tutorial/retrieve_website.php and I get this error: Fatal error: Call to undefined function curl_init() in C:\xampp\htdocs\tutorial\retrieve_website.php on line 14Secor
Problem is probaby in SSL support, run phpinfo() and check if there are following commands/flags: '--with-openssl=/usr' '--with-openssl-dir=/usr', basically you need to compile Apache with SSL support, you should also enable cURL that is couple times faster than FGC, and has numerous options. I have no idea how to do this on Windows, sorry.Shroud
only thing close to that is Configure Command at the top of phpinfo() and that doesn't have anything containing --with-openssl related. it contains other --with things. small update: on localhost, checked status and it says HTTPS (SSL) is activated.Secor
If you invoke return curl_exec($curl);, wouldn't that prevent curl_close($curl); on the next line from executing?Metritis
U
13

I have enable the openssl extention and it work for me :)

;extension=php_openssl.dll

to

extension=php_openssl.dll

Underquote answered 4/4, 2014 at 8:56 Comment(1)
There's no php_openssl.dll, it's just openssl.dll.Redoubtable
C
12

I got this error while attempting to install composer using php cli on Windows. To solve it, I just needed to change the extension directory in php.ini. I had to uncomment this line:

; On windows:
extension_dir = "ext"

Then this one and all things worked

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
;...
extension=openssl
Confide answered 28/9, 2020 at 8:50 Comment(0)
F
9

In my case (PHP 7.3 on Windows in FastCGI mode) it was uncommenting extension=openssl. Not extension=php_openssl, as most people post here.

(The same thing was posted here, but without details on OS which may be a key difference here.)

Flowers answered 28/8, 2019 at 11:40 Comment(0)
I
6

In my case, the issue was due to WAMP using a different php.ini for CLI than Apache, so your settings made through the WAMP menu don't apply to CLI. Just modify the CLI php.ini and it works.

Isologous answered 3/1, 2013 at 16:22 Comment(3)
Wel how did you did it where can I find the CLI php.iniSilicosis
Mine is located here: C:\path\to\wamp\bin\php\php5.3.10\php.iniIsologous
thanks for your answer, I thought there where multiple php.ini files. When I searched I only found one and I uncommented: ;extension=php_openssl.dll But I use xammp I confused it with wamp. Now it works, yeah!Silicosis
P
6

in OpenSuse 12.1 the only thing required was:

zypper in php5-openssl
Prolocutor answered 12/2, 2014 at 5:39 Comment(2)
can you explain please??Lowbred
I mean I got the error message "Unable to find the wrapper “https” - did you forget to enable it when you configured PHP?" and resolved it by entering "zypper in php5-openssl" at the command line. That fixed the error.Prolocutor
O
5

On MAC AMPPS, I updated the php-5.5.ini with the following and now it works.

allow_url_include = On
extension=openssl.so
Orfurd answered 14/11, 2016 at 11:33 Comment(0)
B
5

PHP7, in php.ini file, remove the ";" before extension=openssl

Blacklist answered 4/4, 2018 at 23:16 Comment(1)
This is not enough to fix the problem.Redoubtable
B
4

For me I had to uncomment these lines in php.ini:

extension=php_openssl.dll
extension_dir = "ext"

"ext" is applicable if php_openssl.dll is located in the "ext" folder.

Note: I had to do this for two of my php.ini files otherwise it would not work. One located in the vs.php installation folder, and the other on on the PHP folder

C:\Program Files (x86)\Jcx.Software\VS.Php\2013\Php 5.6
C:\Program Files (x86)\PHP\v5.6

Source

Blithering answered 10/9, 2015 at 17:5 Comment(1)
There's no php_openssl.dll, it's just openssl.dll.Redoubtable
V
4

On newer versions of PHP on Windows, the majority of answers here won't work, since the corresponding configuration lines have changed.

For PHP 7.x, you need to uncomment (remove the ; at the beginning of the line) the following lines:

extension_dir = "ext"
extension=openssl

Vu answered 18/8, 2020 at 1:54 Comment(0)
H
3

You can use this function instead if curl is installed on your system:

function get_url_contents($url){  
  if (function_exists('file_get_contents')) {  
    $result = @file_get_contents($url);  
  }  
  if ($result == '') {  
    $ch = curl_init();  
    $timeout = 30;  
    curl_setopt($ch, CURLOPT_URL, $url);  
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);  
    $result = curl_exec($ch);  
    curl_close($ch);  
  }  

  return $result;  
}
Hamblin answered 21/7, 2013 at 11:3 Comment(0)
C
3

Problem with file_get_contents for the requests https in Windows, uncomment the following lines in the php.ini file:

extension=php_openssl.dll
extension_dir = "ext"
Conchoidal answered 17/7, 2018 at 1:54 Comment(2)
There's no php_openssl.dll, it's just openssl.dll.Redoubtable
in version 7 it is just opensslVenturous
S
2

After snooping around all day, I figured out the answer thanks to this guide: http://piwigo.org/forum/viewtopic.php?id=15727

Basically under Eclipse -> Windows -> Preferences -> PHP Executables, there is a section on where the .exe and .ini is referenced. The defaulted ones were in the Eclipse directory when you install the PHP Development Tools SDK Feature from Eclipses Install New Software in the Help menu.

So instead of that, I added a new executable called PHP 5.3.5 (CGI) and referenced the cgi.exe and .ini from xampp's php folder.

Thank you webarto for giving your time to help me out.

Secor answered 26/3, 2011 at 22:40 Comment(0)
F
2

I'm using opsenSUSE Leap, and I had the same issue -- it means there's no support for OpenSSL. This is how I resolved it:

  1. Open YaST.
  2. Go to Software Management.
  3. In the search box on the left pane, enter 'php5-openssl' and press the return key.
  4. Click the checkbox next to 'php5-openssl' in the right pane to select it, and click 'Accept' (This adds OpenSSL support).
  5. Restart Apache: sudo service apache2 restart

That's it, you're done.

Francklyn answered 26/7, 2016 at 23:0 Comment(0)
I
1

I got this error too. I figured out that my version of PHP didn't have openssl compiled in, so simply adding the extension directive to php.ini wasn't enough. I don't know how you have to solve this in your particular case, but for me, I use macports, and the command was just:

sudo port install php5-openssl
Insulin answered 6/4, 2014 at 19:51 Comment(0)
S
1

For those using Winginx (nginx based instead of Apache based), I fixed it with these 4 steps:

  1. On the Tools menu hit the Winginx PHP5 Config (never mind the 5 in the name...):

    Winginx PHP5 Config

  2. Select the PHP version you want the php.ini to change:

    PHP version selection

  3. On the PHP Extensions tab select the php_openssl extension and hit the Save button:

    php_openssl selection

  4. restart the appropriate PHP service through the taskbar (Stop and Start):

    Restart PHP service

Season answered 20/4, 2018 at 11:7 Comment(0)
S
0

If you are using wamp server then go to icon click on this wamp server icon click on this

Then go to PHP then click on PHP extension there would be php_openssl need to activate from there and restart wamp server active php_openssl from here

Semmes answered 15/10, 2018 at 8:25 Comment(0)
P
0

I had similar issue on Windows. Enabling the extension=openssl and extension_dir = "ext" lines in php.ini, was not enough to fix the issue.

I also had to add the C:\php\ folder to Windows environment path. This is because openssl module need to load some dlls (eg: libcrypto) which are located in php installation folder.

What helped me while troubleshooting this was to check the error.log file in \apache24\logs\ folder. There you will get explicit messages if openssl module cannot be loaded.

Publicity answered 25/10, 2023 at 12:34 Comment(0)
C
0

I had a similar issue with the https request and after a little bit of time messing with my php.ini files I tried just changing the link to http. It works just change the download link and you shouldn't need to enable anything.

The changes that people made to PHP7 probably do work but I am using PHP 8.3. If someone know how to fix it for the php.ini-development and production files, I would love to see comments on it!

Ceresin answered 5/1 at 3:41 Comment(0)
P
-1

Inside the simple_html_dom.php change the value of the $offset variable from -1 to 0. this error usually happens when you migrate to PHP 7.

HtmlDomParser::file_get_html uses a default offset of -1, passing in 0 should fix your problem.

Puppet answered 20/3, 2018 at 5:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.