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

PhpApacheHttpsOpensslXampp

Php Problem Overview


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

Php Solutions


Solution 1 - Php

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.

Solution 2 - Php

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.

Solution 3 - Php

just add two lines in your php.ini file.

extension=php_openssl.dll
allow_url_include = On

its working for me.

Solution 4 - Php

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;
}

Solution 5 - Php

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

;extension=php_openssl.dll

to

extension=php_openssl.dll

Solution 6 - Php

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

Solution 7 - Php

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.

Solution 8 - Php

in OpenSuse 12.1 the only thing required was:

zypper in php5-openssl

Solution 9 - Php

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

Solution 10 - Php

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

allow_url_include = On
extension=openssl.so

Solution 11 - Php

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

Solution 12 - Php

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

Solution 13 - Php

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"

Solution 14 - Php

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;  
}

Solution 15 - Php

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

Solution 16 - Php

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.

Solution 17 - Php

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.

Solution 18 - Php

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

Solution 19 - Php

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

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

PHP version selection

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

php_openssl selection

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

Restart PHP service

Solution 20 - Php

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

Solution 21 - Php

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJohn MView Question on Stackoverflow
Solution 1 - PhpkjetilhView Answer on Stackoverflow
Solution 2 - PhpEzraView Answer on Stackoverflow
Solution 3 - PhpRoopchandView Answer on Stackoverflow
Solution 4 - PhpDejan MarjanovićView Answer on Stackoverflow
Solution 5 - PhpSaran PalView Answer on Stackoverflow
Solution 6 - Php1234ruView Answer on Stackoverflow
Solution 7 - PhpdtbarneView Answer on Stackoverflow
Solution 8 - PhpTheSatinKnightView Answer on Stackoverflow
Solution 9 - PhpKarobweView Answer on Stackoverflow
Solution 10 - PhpElyeView Answer on Stackoverflow
Solution 11 - PhpShusen YiView Answer on Stackoverflow
Solution 12 - PhpzetaView Answer on Stackoverflow
Solution 13 - PhpSandraView Answer on Stackoverflow
Solution 14 - Phpactors315View Answer on Stackoverflow
Solution 15 - PhpVitoxView Answer on Stackoverflow
Solution 16 - PhpJohn MView Answer on Stackoverflow
Solution 17 - PhpmtchuenteView Answer on Stackoverflow
Solution 18 - PhpmasonView Answer on Stackoverflow
Solution 19 - PhpCPHPythonView Answer on Stackoverflow
Solution 20 - PhpML680View Answer on Stackoverflow
Solution 21 - PhpTgold brainView Answer on Stackoverflow