From: llongo at sata-hts dot com Operating system: solaris 8 PHP version: 5.2.9 PHP Bug Type: Streams related Bug description: stream_socket_client with tls gives an unknown error on solaris 8
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 bug report at http://bugs.php.net/?id=47862&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47862&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47862&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47862&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47862&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47862&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47862&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47862&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47862&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47862&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47862&r=support Expected behavior: http://bugs.php.net/fix.php?id=47862&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47862&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47862&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47862&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47862&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47862&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47862&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47862&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47862&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47862&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47862&r=mysqlcfg