ID:               47862
 Updated by:       j...@php.net
 Reported By:      llongo at sata-hts dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Streams related
 Operating System: solaris 8
 PHP Version:      5.2.9
 New Comment:

Check the openssl versios in the working / failing servers.


Previous Comments:
------------------------------------------------------------------------

[2009-04-01 13:32:40] 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


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=47862&edit=1

Reply via email to