|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47862 stream_socket_client with tls gives an unknown error on solaris 8
Submitted: 2009-04-01 13:32 UTC Modified: 2009-04-09 01:00 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: llongo at sata-hts dot com Assigned:
Status: No Feedback Package: Streams related
PHP Version: 5.2.9 OS: solaris 8
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-04-01 13:32 UTC] llongo at sata-hts dot com
The client script should connect through tls to server and send him some messages, but an error occurs and the tls connection cannot be established. The client script works fine on CentOS 5 (x86_64) and Solaris 10 (x86), but gives the error reported only on Solaris 8 (sparc) [tls is supported], while server script always runs on CentOS5 (x86_64).

This is the configure option for php:
./configure \
	    --enable-xml \
	    --enable-libxml \
	    --with-tsrm-pthreads \
	    --with-openssl \
	    --with-zlib \
	    --with-pcre-regex \
	    --with-pear \
	    --enable-sysvsem \
	    --enable-sysvshm \
	    --enable-sysvmsg \
	    --enable-shmop \
	    --enable-pcntl \
	    --with-gettext \
	    --enable-sockets \
	    --enable-mbstring \
	    --with-imap-ssl \
	    --with-mcrypt \
	    --disable-cgi \

Reproduce code:
// client
$context = stream_context_create(array('tls'=>array('capture_peer_cert'=>TRUE)));
$fp = stream_socket_client("tls://", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
if (!$fp) {
	die("error creating socket (".$errno."):".$errstr."\n");
$i_sleep = 1;
for ($i_counter = 0; $i_counter < 10; $i_counter++) {
	$s_msg = "message sent ".$i_counter;

// server
$context = stream_context_create();     // context creation
// substitute mycert.pem with your certificate
stream_context_set_option($context, 'ssl', 'local_cert','mycert.pem'); 
stream_context_set_option($context, 'ssl', 'passphrase', 'SecureLog');
stream_context_set_option($context, 'ssl', 'allow_self_signed', true);
stream_context_set_option($context, 'ssl', 'verify_peer', false);
$socket = stream_socket_server("tls://", $errno, $errstr,STREAM_SERVER_BIND|STREAM_SERVER_LISTEN,$context);  // substitute the ip with your own ip
if (!$socket) die($errstr.": (".$errno.")\n");
if (false == ($conn = stream_socket_accept($socket,-1))) die("error waiting for connection\n");
while(1) {
        $ah_read = array($conn);
        $i_result = stream_select($ah_read,$ah_write = null,$ah_except = null,1);
        if($i_result === false) die("socket error\n");  // socket error
        if($i_result > 0){
                $data = fread($conn,8192);
                if($data == "") {
                        die("socket error reading\n");
                echo "MESSAGE RECEIVED: ".$data."\n";

Expected result:
Client connects to server, sends 10 messages and then exits. The server output is:

MESSAGE RECEIVED: message sent 0
MESSAGE RECEIVED: message sent 1
MESSAGE RECEIVED: message sent 2
MESSAGE RECEIVED: message sent 3
MESSAGE RECEIVED: message sent 4
MESSAGE RECEIVED: message sent 5
MESSAGE RECEIVED: message sent 6
MESSAGE RECEIVED: message sent 7
MESSAGE RECEIVED: message sent 8
MESSAGE RECEIVED: message sent 9
socket error reading

Actual result:
Client doesn't connect to server and the output is:

Warning: stream_socket_client(): SSL: Error 0 in /client.php on line 2

Warning: stream_socket_client(): Failed to enable crypto in /client.php on line 2

Warning: stream_socket_client(): unable to connect to tls:// (Unknown error) in /client.php on line 2
error creating socket (0):

PHP Warning:  stream_socket_accept(): Failed to enable crypto in /server.php on line 9

Warning: stream_socket_accept(): Failed to enable crypto in /server.php on line 9
PHP Warning:  stream_socket_accept(): accept failed: Success in /server.php on line 9

Warning: stream_socket_accept(): accept failed: Success in /server.php on line 9
error waiting for connection


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-01 13:34 UTC]
Check the openssl versios in the working / failing servers.
 [2009-04-02 07:21 UTC] llongo at sata-hts dot com
The openssl version of solaris 8 (sparc) is 0.9.8k (downloaded from, while in the Solaris 10 the openssl version is 0.9.7 and in CentOS 5 is 0.9.8b.
 [2009-04-02 08:44 UTC] llongo at sata-hts dot com
I've solved the problem installing the patch 112438 for Solaris 8, which does not have natively support for /dev/urandom and /dev/random.

Thanks for your help, this is not a php bug.
 [2009-04-09 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".
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 01:01:31 2024 UTC