php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62960 non block stream does not work with ssl
Submitted: 2012-08-28 19:07 UTC Modified: 2022-08-05 21:08 UTC
Votes:5
Avg. Score:5.0 ± 0.0
Reproduced:5 of 5 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: jim dot javathunderbird at gmail dot com Assigned: bukka (profile)
Status: Not a bug Package: Streams related
PHP Version: 5.4.6 OS: CentOS 64 bit
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
10 + 42 = ?
Subscribe to this entry?

 
 [2012-08-28 19:07 UTC] 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";
  }
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-03 10:24 UTC] 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?
 [2014-04-03 10:58 UTC] 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.
 [2022-08-05 21:08 UTC] bukka@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: bukka
 [2022-08-05 21:08 UTC] bukka@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Mar 02 23:01:32 2024 UTC