ID:               48182
 User updated by:  frase at cs dot wisc dot edu
-Summary:          ssl handshake fails during asynchronous socket
                   connection
 Reported By:      frase at cs dot wisc dot edu
-Status:           Closed
+Status:           Open
 Bug Type:         OpenSSL related
 Operating System: *
-PHP Version:      5.2.10, 5.3.0
+PHP Version:      5.2.11RC1
 Assigned To:      srinatar
 New Comment:

I'm re-opening this bug as the fix appears not to work in 5.2.11RC1. 
With the same testing code as in the original report, when connecting
synchronously, all is well.  But when connecting asynchronously I get
these warnings:


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

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

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 14


Line 14 is of course the stream_socket_client() call.  Additionally,
after these warnings, $errno contains 10035 and $errstr is empty.


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

[2009-07-28 19:34:15] srina...@php.net

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Committed revision 286465.

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

[2009-07-10 13:38:01] frase at cs dot wisc dot edu

The supplied patch does fix the problem in 5.3.0 on Linux; I have no
Windows build environment so I can't test it there but can't see why it
wouldn't also work.  Since the patch was to OpenSSL I've changed the
category back.

Many thanks!

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

[2009-07-09 21:53:03] sriram dot natarajan at gmail dot com

better still, here is the patch (more readable format)
http://pastebin.org/805

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

[2009-07-09 21:47:44] sriram dot natarajan at gmail dot com

thanks for your patience.

here is a patch that should address your issue. to apply this patch,
save the above text into a file and run

--- ext/openssl/xp_ssl.c.ORIG   Thu Jul  9 12:20:44 2009
+++ ext/openssl/xp_ssl.c        Thu Jul  9 12:29:18 2009
@@ -672,7 +672,11 @@
                                         * we notice that the connect
has actually been established */
                                       
php_stream_socket_ops.set_option(stream, option, value, ptrparam
TSRMLS_CC);
 
-                                       if (xparam->outputs.returncode
== 0 && sslsock->enable_on_connect) {
+                                       if
((sslsock->enable_on_connect) &&
+                                              
((xparam->outputs.returncode == 0) ||
+                                                (xparam->op ==
STREAM_XPORT_OP_CONNECT_ASYNC && xparam->outputs.returncode == 1 && 
+                                               
xparam->outputs.error_code == EINPROGRESS)))
+                                       {
                                                if
(php_stream_xport_crypto_setup(stream, sslsock->method, NULL TSRMLS_CC)
< 0 ||
                                                               
php_stream_xport_crypto_enable(stream, 1 TSRMLS_CC) < 0) {
                                                       
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to enable crypto");


- download and unzip the latest php 5.3snapshot from
http://snaps.php.net
- cd <php-workspace> ; patch -p0 -d . < <filename>

now, you can run make and should be able to test it.

i will wait for some one to review this patch . hopefully, should
happen before next release :-)

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

[2009-07-01 16:28:14] frase at cs dot wisc dot edu

This bug remains also in 5.2.10.

Let's try a new summary and changing the category to "Sockets", maybe
it will get someone's attention.

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/48182

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

Reply via email to