ID:               35105
 Updated by:       [EMAIL PROTECTED]
 Reported By:      wckits at rit dot edu
-Status:           Assigned
+Status:           Feedback
 Bug Type:         Sockets related
 Operating System: SunOS 5.9
 PHP Version:      5.0.5
 Assigned To:      wez
 New Comment:

Please try using this CVS snapshot:

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




Previous Comments:
------------------------------------------------------------------------

[2005-11-04 16:25:24] [EMAIL PROTECTED]

Assigned to the streams author and maintainer.


------------------------------------------------------------------------

[2005-11-04 15:07:58] wckits at rit dot edu

Description:
------------
A stream opened with stream_socket_client("ssl://..... will not timeout
when reading.

This may have a similar underlying cause to bug #23618 but it is
exposed differently, and is still a problem in 5.0.5.

Reproduce code:
---------------
#!/bin/php-5.0.5/sapi/cli/php
<?
//First connect and do something to prove that we are properly
connected.

print "Setting up context\n";
$ctx = stream_context_create(array(
                        'ssl'=>array(
                                'verify_peer' => false,
                                'allow_self_signed' => true,
                                )
                        ));
print "Creating socket\n";
$socket = stream_socket_client( "ssl://www.rit.edu:443", &$errno,
&$errstr, 10, STREAM_CLIENT_CONNECT, $ctx );
print "Setting timeout\n";
var_dump(stream_set_timeout( $socket, 5 ));
print "Sending bogus request\n";
fwrite($socket, "GET nourl Cupcakes/2.5\n\n\n\n" );
print "Reading Result\n";
var_dump(fgets( $socket));

//Now conenct and read when we know the server isnt going to send
anything

print "Creating NEW socket\n";
$socket = stream_socket_client( "ssl://www.rit.edu:443", &$errno,
&$errstr, 10, STREAM_CLIENT_CONNECT, $ctx );
print "Setting timeout\n";
var_dump(stream_set_timeout( $socket, 5 ));
print "Sending NO request\n";
print "Read should time out in 5....\n";
var_dump(fgets( $socket));
?>


Expected result:
----------------
The first section will run and print an HTTP error. The second section
will run and timeout after printing "Read should timeout in 5..."

Actual result:
--------------
Read does not time out.

I suspect that the read timeout on SSL connections is just not
implemented, because it is hard, but if that is the case the
stream_set_timeout should return false to indicate the error.

If its just not implemented I'd be willing to patch it up if there is
one place to fix it. If there are ssl reads all over the php source I
don't think I'd have the time to track them all down.

I have seen people say "just use select" in response to stream timeout
problems. That does not work with ssl, or at least it may not always
work with ssl. Select can be used if you have access to the native SSL
interface (ie: it could be done right in C) but you need to be able to
check for the WANT_READ condition....


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=35105&edit=1

Reply via email to