Bug #62960 [Opn->Nab]: non block stream does not work with ssl
Edit report at https://bugs.php.net/bug.php?id=62960&edit=1
ID: 62960
Updated by: bukka@php.net
Reported by: jim dot javathunderbird at gmail dot com
Summary: non block stream does not work with ssl
-Status: Open
+Status: Not a bug
Type: Bug
Package: Streams related
Operating System: CentOS 64 bit
PHP Version: 5.4.6
-Assigned To:
+Assigned To: bukka
Block user comment: N
Private report: N
New Comment:
This is unlikely an issue in PHP as this has been working fine for years. Maybe there was an issue
that got fixed but think it's more likely application usage issue - for example I don't
see any use of stream_select in the example which is often needed for non blocking read. Also note
that stream_socket_accept will return blocking socket on Linux so that might have been confusing as
well. Anyway non blocking read with TLS is definitely working if used correctly. If you still
experience, please open a new issue in GitHub with more details what exactly doesn't work for
you.
Previous Comments:
------------------------------------------------------------------------
[2014-04-03 10:58:00] heruan at aldu dot net
Note that *writing* to the encrypted stream seems working, it's *reading* that won't work
and it is reported on #65137.
------------------------------------------------------------------------
[2014-04-03 10:24:24] heruan at aldu dot net
No one has ever given a feedback to this bug. It still affects PHP 5.5.9, any chance to get this
fixed in 5.6?
------------------------------------------------------------------------
[2012-08-28 19:07:12] jim dot javathunderbird at gmail dot com
Description:
------------
When using stream_socket_server with non blocking stream, there seems to have no way to write buffer
to client. When the stream is in blocking mode, things start working again.
Test script:
---------------
<?php
$protocol = "ssl";
$ip = "127.0.0.1";
$port = 8000;
$context = stream_context_create();
$certificate = __DIR__."/certificate_concat.pem";
stream_context_set_option($context, 'ssl', 'local_cert', $certificate);
stream_context_set_option($context, 'ssl', 'verify_peer', false);
$server = stream_socket_server("$protocol://$ip:$port", $errno, $errstr,
STREAM_SERVER_BIND|STREAM_SERVER_LISTEN, $context);
stream_set_blocking($server, 0); //when set to non blocking, ssl will not work, if set to blocking,
things start working again
while(true)
{
$client = stream_socket_accept($server);
print "accepted " . stream_socket_get_name( $client, true) . "\n";
if( $client )
{
fwrite($client, "hello");
} else {
print "error.\n";
}
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62960&edit=1
Thread (4 messages)