From: chad at herballure dot com Operating system: Linux PHP version: 5.2.4RC2 PHP Bug Type: Streams related Bug description: Error notification callback not called
Description: ------------ The streams API doesn't appear to actually call the error callback. This is definitely true if the connection fails, or if the expected hostname doesn't match the SSL certificate. In the latter case, there is no reliable way of detecting the error. The reproduce code is a cut-down version of a test script being run through the CLI, while I figure out the streams API. I get the same behavior from 5.2.3 and 5.2.4RC2. Reproduce code: --------------- <?php $HOST_NAME = 'secureservicesonline.com'; $CA_DIR = '/etc/ssl/certs'; // change this if needed function stream_err() { $args = func_get_args(); echo("[stream_err, args="); print_r($args); // which are undocumented, btw echo("]\n"); } $ctx = stream_context_create(array('ssl'=>array('verify_peer' => true, 'CN_match' => "$HOST_NAME.invalid", 'capath'=>$CA_DIR))); $ret = stream_context_set_params($ctx, array('notification'=>'stream_err')); var_dump($ret); $errno = $errstr = null; $fp = stream_socket_client("ssl://$HOST_NAME:443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $ctx); var_dump($errno); var_dump($errstr); if( $fp !== false ) { fclose($fp); } ?> Expected result: ---------------- [stream_err, args=Array ( ...... )] Actual result: -------------- PHP Warning: stream_socket_client(): Peer certificate CN=`secureservicesonline.com' did not match expected CN=`secureservicesonline.com.invalid' in /.../https_client.php on line 52 Warning: stream_socket_client(): Peer certificate CN=`secureservicesonline.com' did not match expected CN=`secureservicesonline.com.invalid' in /.../https_client.php on line 52 -- Edit bug report at http://bugs.php.net/?id=42387&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42387&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42387&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42387&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42387&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42387&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42387&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42387&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42387&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42387&r=support Expected behavior: http://bugs.php.net/fix.php?id=42387&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42387&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42387&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42387&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42387&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42387&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42387&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42387&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42387&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42387&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42387&r=mysqlcfg