PHP : fsockopen – Unable to find the socket transport “ssl” – did you forget to enable it when you configured PHP?

You might get error – “Unable to find the socket transport “ssl” – did you forget to enable it when you configured PHP?” when you are trying fsockopen() function of PHP. If your PHP is not compiled with open_ssl support then you could not open a secured connection through fsockopen(). We can test the code snippet here –

$fp = fsockopen("ssl://www.google.com", 443, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: www.google.com\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}

If open_ssl is not complied with PHP or it is not enabled from php.ini file, you will see that error.

Solution in Linux:

Compile PHP with open_ssl, command-

–with-openssl[=DIR]    Include OpenSSL support (requires OpenSSL >= 0.9.6)

Windows with  XAMP:

  1. Stop your Apache service
  2. Find libeay32.dll and ssleay32.dll in xampp\php\ folder, and copy it into  xampp\apache\bin\ folder. Overwrite the older files in there.
  3. Edit php.ini file in xampp\apache\bin, remove the semicolon in “;extension=php_openssl.dll
  4. Start the Apache service

Windows with  WAMP2:

  1. From WAMP tray menu, go to PHP Extension
  2. Check php_openssl
  3. Apache will be restarted

You are done!


All comments of post - "PHP : fsockopen – Unable to find the socket transport “ssl” – did you forget to enable it when you configured PHP?":

:Haha! I'am the first! Yeh~

Comments are currently closed.

Add a Comment / Trackback url

Comment begin from here or jump up!