53

I'm having trouble enabling the socket transport "ssl" in PHP. When I run my script, I get the error:

Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://www.my.site.com:443 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?)

I'm running IIS6 on Windows and this is what I've done so far to try to get it working:

  • uncommented the php_openssl.dll and php_sockets.dll extensions in php.ini
  • made sure PHP was loading the ini file I made changes to (it is, and it's definitely loading other extensions, so I'm fairly sure this isn't the problem)
  • made sure php_openssl.dll and php_sockets.dll were in the correct location
  • copied ssleay32.dll and libeay32.dll to the main PHP folder, the WINDOWS folder and the WINDOWS/system32 folder
  • made sure the Windows path variable included the location of PHP
  • made sure the file permissions were correct on all the relevant files.

I've restarted IIS after pretty much every change, but I haven't had any luck. Is there anything obvious that I'm doing wrong? Is there anyway to troubleshoot this in smaller parts? (So I can figure out the problem by the process of elimination...?)

Unfortunately Windows/IIS aren't my area of expertise--I've been put in charge because nobody else seems to know anything.

Michael Irigoyen
  • 22,513
  • 17
  • 89
  • 131
jelina
  • 841
  • 1
  • 6
  • 9
  • 1
    how you php.log is looking, if you don't have enabled the logging please do so. – RageZ Nov 10 '09 at 05:45
  • To expand on @RageZ's comment: is 'display_startup_errors' turned on in php.ini? – Ben Dunlap Nov 10 '09 at 06:00
  • Yep, we do have logging enabled... but being the n00b that I am, I completely forgot to check >_< The error we're getting is: "PHP Warning: PHP Startup: Unable to load dynamic library 'C:\PHP\ext\php_openssl.dll' - Access is denied." After seeing that, I thought it may have been a permissions problem with php_openssl.dll, but we compared it to another dll in that folder (that we know is loading) and they appear to have the same permissions and groups. Is there something else that might be stopping this dll from loading? – jelina Nov 11 '09 at 00:18

7 Answers7

69

I was having problem in Windows 7 with PHP 5.4.0 in command line, using Xampp 1.8.1 server. This is what i did:

  1. Rename php.ini-production to php.ini (in C:\xampp\php\ folder)
  2. Edit php.ini and uncomment extension_dir=ext.
  3. Also uncomment extension=php_openssl.dll.

After that it worked fine.

cikatomo
  • 1,620
  • 2
  • 23
  • 32
  • 1
    Using WampServer 2.2 I just edit `php.ini` in `C:\wamp\bin\php\php5.3.13` then uncomment `extension=php_openssl.dll`. – Rubens Mariuzzo May 26 '13 at 00:14
  • 13
    Just uncommenting the extension=php_openssl.dll and restarting Apache worked for me as well. – Layton Everson Jun 02 '13 at 00:27
  • 6
    Thanks alot. It almost made me cry :-) – M. Ahmad Zafar Jun 28 '13 at 06:01
  • Thanks, Wamp had used another php.ini file than the php.ini in "C:\wamp\bin\php\phpversion\php.ini" I had to uncomment open_sll extension in this php.ini file and not in the php.ini proposed by wamp. I hope this will help anyone who has the same problem. – csblo Jul 24 '14 at 08:39
  • worked for me on 5.6.11, I can now read a https url with $data = file_get_contents($url); – medloh Jul 11 '15 at 00:09
  • This is a red herring answer because it tries to evade the problem instead of fixing it. In reality you only need the settings as described in http://stackoverflow.com/questions/1705856/socket-transport-ssl-in-php-not-enabled#comment50821413_1712644 – Pacerier Jul 15 '15 at 08:19
21

Success!

After checking the log files and making sure the permissions on php_openssl.dll were correct, I googled the warning and found more things to try.

So I:

  • added C:\PHP\ext to the Windows path
  • added libeay32.dll and ssleay32.dll to C:\WINDOWS\system32\inetsrv
  • rebooted the server

I'm not sure which of these fixed my problem, but it's definately fixed now! :)

I found these things to try on this page: http://php.net/manual/en/install.windows.extensions.php

Thanks for your help!

jelina
  • 841
  • 1
  • 6
  • 9
  • @RubensMariuzzo thanks, but I've already solved, the issue was with my 64-bit system and the solution was to copy a few DLLs on some locations, I don't remember the exact steps. – coding_idiot May 26 '13 at 07:58
  • @taarradhin, There's no need for libeay32.dll and ssleay32, you only need 3 things: – Pacerier Jul 15 '15 at 08:13
  • 1
    @coding_idiot, **1)** `extension_dir` must point to the folder which **both** `php_sockets.dll` and `php_openssl.dll` are in and **2)** you must have the lines `extension=php_openssl.dll` and `extension=php_sockets.dll` and **3)** make sure their values are not overwritten by the same key below. This is very common. Just that 3 and you are done. – Pacerier Jul 15 '15 at 08:15
  • Tearing my hear out on this one today and definitely those 3 things are not enough. Nor does copying the two DLL files. Very maddening that there isn't an actual, straightforward XAMPP/Windows10/64-bit solution to this problem... am considering re-installing XAMPP whatever latest version from the ground up at this point. – CK MacLeod Mar 03 '17 at 21:09
7

In XAMPP Version 1.7.4 server does not have extension=php_openssl.dll line in php ini file. We have to add extension=php_openssl.dll in php.ini file

Selvakumar
  • 71
  • 1
  • 1
7

Ran into the same problem on Laravel 4 trying to send e-mail using SSL encryption.

Having WAMPServer 2.2 on Windows 7 64bit I only enabled php_openssl in the php.ini, restarted WAMPServer and worked flawlessly.

Did following:

  • Click WampServer -> PHP -> PHP extensions -> php_openssl
  • Restart WampServer
Marko Aleksić
  • 1,591
  • 1
  • 18
  • 24
7

Just uncomment extension=php_openssl.dll Restart Apache Service and that should help.

Yogesh Unavane
  • 265
  • 3
  • 11
1

I also ran into this issue just now while messing with laravel.

I am using wampserver for windows and had to copy the /bin/apache/apacheversion/bin/php.ini file to /bin/php/phpversion/php.ini

Dale
  • 10,384
  • 21
  • 34
0

I am using XAMPP and came across the same error. I had done all those steps, added environmental variables path, copied the dll's every directory possible, to /php, /apache/bin, /system32, /syswow64, etc.. but still got this error.

Then after checking the apache error log, I noticed the issue with using brackets in path.

PHP: syntax error, unexpected '(' in C:\Program Files (other)\xampp\php\php.ini on line 707 0 server certificate does NOT include an ID which matches the server name

If you have installed the server in "Program Files (x86)" directory, the same error might occur due to the non-escaped brackets.

To fix this, open php.ini file and locate the line containing "include_path" and enclose the path with double quotes to fix this error.

include_path="C:\Program Files (other)\xampp\php\PEAR"

Ajay Singh
  • 692
  • 8
  • 19