From:             frase at cs dot wisc dot edu
Operating system: Win 2000 Pro SP4
PHP version:      5.2.11RC1
PHP Bug Type:     OpenSSL related
Bug description:  stream_socket_client() fails on SSL+async

Description:
------------
stream_socket_client() can only open one socket using SSL and the
STREAM_CLIENT_ASYNC_CONNECT flag, and then fails every time until the
Apache process is restarted.  SSL sockets without ASYNC open fine, as do
plain TCP sockets with or without ASYNC.

Originally reported as an update to bug #48182, which also only affected
the combination of SSL+ASYNC, but now reported separately here per
srina...@php.net's request.

Additionally, the timeout (argument #4 to stream_socket_client()) is not
ignored when using ASYNC, contrary to the manual: if set to 0 here, the
first warning is "SSL: connection timeout" instead of "SSL: The operation
completed successfully."

Windows 2000 Professional SP4
Apache 2.2.11
PHP 5.2.11RC1-Win32-VC6-x86 (threadsafe binary from
http://windows.php.net/qa/)
configured as an Apache module
with php_openssl.dll and libeay32.dll+ssleay.dll v0.9.8k


Reproduce code:
---------------
<?php
header('Content-Type: text/plain');
$errno = null;
$errstr = null;
$socket = stream_socket_client(
                'ssl://'.gethostbyname('launchpad.net').':443', $errno, $errstr,
                10, // timeout should be ignored when ASYNC
                STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT
);
if (!$socket) {
        echo "errno = ".$errno."\nerrstr = ".$errstr."\n";
        exit;
}
stream_set_blocking($socket, 0);
$data = "GET / HTTP/1.0\r\nHost: launchpad.net\r\nConnection:
close\r\n\r\n";
$selR = null;
$selW = array();
$selE = null;
while ($data) {
        $selW[0] = $socket;
        if (stream_select($selR, $selW, $selE, 10)) {
                $wrote = fwrite($socket, $data, strlen($data));
                $data = substr($data, $wrote);
        }
}
$html = "";
$selR = array($socket);
$selW = null;
while (!feof($socket)) {
        $selR[0] = $socket;
        if (stream_select($selR, $selW, $selE, 10))
                $html .= fread($socket, 8192);
}
fclose($socket);
echo "OK!\n----------\n".$html;


Expected result:
----------------
OK!
----------
(HTTP headers and content from launchpad.net)

Actual result:
--------------
Warning: stream_socket_client() [function.stream-socket-client]: SSL: The
operation completed successfully. in test-async-ssl.php on line 8

Warning: stream_socket_client() [function.stream-socket-client]: Failed to
enable crypto in test-async-ssl.php on line 8

Warning: stream_socket_client() [function.stream-socket-client]: unable to
connect to ssl://91.189.90.211:443 (Unknown error) in test-async-ssl.php on
line 8
errno = 10035 errstr = 


-- 
Edit bug report at http://bugs.php.net/?id=49295&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=49295&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=49295&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=49295&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=49295&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=49295&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=49295&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=49295&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=49295&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=49295&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=49295&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=49295&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=49295&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=49295&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=49295&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=49295&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=49295&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=49295&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=49295&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=49295&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=49295&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=49295&r=mysqlcfg

Reply via email to