php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50192 SSL Success, Failed to enable crypto
Submitted: 2009-11-16 19:00 UTC Modified: 2009-12-21 01:00 UTC
Votes:4
Avg. Score:3.8 ± 0.4
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: pablo at bng5 dot net Assigned:
Status: No Feedback Package: Apache2 related
PHP Version: 5.2.6 OS: Ubuntu 8.10/9.04
Private report: No CVE-ID: None
 [2009-11-16 19:00 UTC] pablo at bng5 dot net
Description:
------------
Cannot open a secure socket with 'fsockopen' function.

My PHP Version is 5.2.6-3ubuntu4.2, I installed it from the Ubuntu repositories, this is the latest PHP version I can get from there.

The same script works fine with PHP-CLI, but throws an error on Apache2 (same PHP installation).

Excuse my english.

Reproduce code:
---------------
<?php
$host = 'www.mozilla.com';
$port = 443;
$path = '/es-ES/';
$headers = 'GET '.$path.' HTTP/1.0
Host: '.$host.'

';
$fp = fsockopen("ssl://".$host, $port, $errno, $errstr, 30);
if($fp)
 {
  fwrite($fp, $headers);
  while($string = trim(fgets($fp, 4096)))
   {
    echo $string."\n";
   }
 }
?>


Expected result:
----------------
-- This is the actual result on PHP-CLI
-- PHP Version => 5.2.6-3ubuntu4.2
-- 
-- System => Linux wintermute 2.6.28-16-generic #55-Ubuntu SMP Tue Oct 20 19:48:24 UTC 2009 i686
-- Build Date => Aug 21 2009 19:12:00
-- Server API => Command Line Interface

HTTP/1.0 200 OK
Date: Mon, 16 Nov 2009 18:39:02 GMT
Expires: Mon, 16 Nov 2009 18:54:02 GMT
Cache-Control: max-age=900
Xontent-Length:
Connection: Close
Via: NS-CACHE-6.0:   4
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.1.6
Content-Type: text/html; charset=UTF-8


Actual result:
--------------
-- PHP Version => 5.2.6-3ubuntu4.2
-- 
-- System => Linux wintermute 2.6.28-16-generic #55-Ubuntu SMP Tue Oct 20 19:48:24 UTC 2009 i686
-- Build Date => Aug 21 2009 18:45:50
-- Server API => Apache 2.0 Handler 


Warning: fsockopen() [function.fsockopen]: SSL: Success in /home/user/public_html/fsockopen.php on line 14

Warning: fsockopen() [function.fsockopen]: Failed to enable crypto in /home/user/public_html/fsockopen.php on line 14

Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://www.mozilla.com:443 (Unknown error) in /home/user/public_html/fsockopen.php on line 14

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-17 09:27 UTC] jani@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-11-25 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-12-13 18:22 UTC] felipe@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

I cannot reproduce it.
 [2009-12-21 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2011-07-13 12:32 UTC] daniel dot meister at datahouse dot ch
Just in case somebody else finds this via Google:

I encountered this exact same problem today on a Debian Lenny with PHP 5.2.6: Starting the script from the CLI interface worked perfectly; starting the same script via Apache produced the described error.

It turned out to be a permission problem on "/dev/urandom" (rw-rw----, root:root) and not a PHP bug!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 11:01:30 2024 UTC