php.net |  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
Votes:1
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
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 — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
2 + 5 = ?
Subscribe to this entry?

 
 [2009-04-01 13:32 UTC] llongo at sata-hts dot com
Description:
------------
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 \
	    --with-gnu-ld



Reproduce code:
---------------
<?php
// client
$context = stream_context_create(array('tls'=>array('capture_peer_cert'=>TRUE)));
$fp = stream_socket_client("tls://192.168.14.200:8000", $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;
	fwrite($fp,$s_msg);
	sleep($i_sleep);
}
fclose($fp);
?>

<?php
// 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://192.168.14.200:8000", $errno, $errstr,STREAM_SERVER_BIND|STREAM_SERVER_LISTEN,$context);  // substitute the ip 192.168.14.200 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 == "") {
                        fclose($socket);
                        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:

CLIENT:
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://192.168.14.200:8000 (Unknown error) in /client.php on line 2
error creating socket (0):

SERVER:
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-01 13:34 UTC] jani@php.net
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 http://www.sunfreeware.com/indexsparc8.html), 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.
(http://sunsolve.sun.com/search/document.do?assetkey=1-21-112438-03-1)

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: Wed Apr 24 00:01:32 2024 UTC