ID: 49295 Comment by: frase at cs dot wisc dot edu Reported By: frase at cs dot wisc dot edu Status: Assigned Bug Type: OpenSSL related Operating System: Win 2000 Pro SP4 PHP Version: 5.2.11RC1 Assigned To: srinatar New Comment:
I had a chance to compile and test PHP5.2.11RC1 under Linux this morning (Ubuntu Jaunty, Apache 2.2.11 from repositories), and these warnings do not appear, however I noticed another problem. Although the SSL+async connection is successful and data is returned under Linux, the socket is not actually opened asynchonously. The script blocks until the socket has finished opening, exactly as it does without the ASYNC flag. This is also true under Windows, for the first run -- after that, of course, it returns the errors posted above. Previous Comments: ------------------------------------------------------------------------ [2009-08-21 01:15:44] srina...@php.net this issue seems to be happening when this script is executed more than once and also seems to be happening only on windows. ------------------------------------------------------------------------ [2009-08-19 13:52:18] frase at cs dot wisc dot edu 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 this bug report at http://bugs.php.net/?id=49295&edit=1