php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35105 stream_set_timeout() has no effect on SSL stream
Submitted: 2005-11-04 15:07 UTC Modified: 2006-12-30 02:35 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: wckits at rit dot edu Assigned: wez (profile)
Status: Closed Package: Streams related
PHP Version: 5CVS-2005-11-08 (snap) OS: SunOS 5.9
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: wckits at rit dot edu
New email:
PHP Version: OS:

 

 [2005-11-04 15:07 UTC] 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....

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-08 19:43 UTC] wckits at rit dot edu
'Latest' (php5-200511081330) just wont build on my system, same configuration as 5.0.5... Unless you are willing to cut and paste the example code into your own latest cvs build this may have to wait for the next stable release.
 [2005-11-08 20:14 UTC] sniper@php.net
Guess what? The snapshot you tried IS the next stable release.
So can you please tell us what didn't work with it?
Just saying "it wont build" does not help much..

 [2005-11-08 21:07 UTC] wckits at rit dot edu
Ok, I figured it was just the copy in cvs being broken (some feature half done or some such), I wasn't trying to be a jerk. I had to add -mimpure-text to CFLAGS for the last few linking steps to fix the problem (otherwise I'd get about 16,000 lines of linker errors).

Anyway:

> /u01/wckits/php5-200511081730/sapi/cli/php
<?phpinfo()?>

phpinfo()
PHP Version => 5.1.0RC5-dev

System => SunOS myHostname 5.9 Generic_117171-13 sun4u
Build Date => Nov  8 2005 14:52:09


The timeout problem still exists in php5-latest.
 [2005-11-08 21:31 UTC] sniper@php.net
Assigned to the maintainer and author of streams.

 [2006-12-30 02:35 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2013-01-19 18:06 UTC] bbroerman at bbroerman dot net
I can still recreate this issue in the current 5.4 branch of PHP.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC