]> granicus.if.org Git - php/commitdiff
Improve fix for Bug #68344 MySQLi does not provide way to disable peer certificate...
authorAndrey Hristov <andrey@php.net>
Thu, 22 Oct 2015 09:48:53 +0000 (11:48 +0200)
committerAndrey Hristov <andrey@php.net>
Thu, 22 Oct 2015 09:48:53 +0000 (11:48 +0200)
ext/mysqli/mysqli.c
ext/mysqli/tests/mysqli_constants.phpt
ext/mysqlnd/mysqlnd_net.c

index e028d60ab0c469e597061609843b92814d088383..198ed8311660bc76db01e1012cfa617641cedd66 100644 (file)
@@ -715,6 +715,9 @@ PHP_MINIT_FUNCTION(mysqli)
        REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_IGNORE_SPACE", CLIENT_IGNORE_SPACE, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_NO_SCHEMA", CLIENT_NO_SCHEMA, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_FOUND_ROWS", CLIENT_FOUND_ROWS, CONST_CS | CONST_PERSISTENT);
+#ifdef CLIENT_SSL_VERIFY_SERVER_CERT
+       REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_SSL_VERIFY_SERVER_CERT", CLIENT_SSL_VERIFY_SERVER_CERT, CONST_CS | CONST_PERSISTENT);
+#endif
 #if (MYSQL_VERSION_ID >= 50611 && defined(CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS)) || defined(MYSQLI_USE_MYSQLND)
        REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS", CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS", MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, CONST_CS | CONST_PERSISTENT);
index dd0f769e91677071d83b6ef66a7f9ecc94615cd5..1cb31cc2a72aef891ea49d4688fbeafc49e43afe 100644 (file)
@@ -136,6 +136,9 @@ require_once('skipifconnectfailure.inc');
                $expected_constants['MYSQLI_SERVER_QUERY_WAS_SLOW'] = true;
        }
 
+       if ($version >= 50033 || $IS_MYSQLND) {
+               $expected_constants['MYSQLI_CLIENT_SSL_VERIFY_SERVER_CERT'] = true;
+       }
 
        /* First introduced in MySQL 6.0, backported to MySQL 5.5 */
        if ($version >= 50606 || $IS_MYSQLND) {
index 4cbe9deb29626e4b25f6147ca73e11839d5714e8..7b164ac29424b06f46807cb5655f0cb8ea5a596c 100644 (file)
@@ -897,14 +897,9 @@ MYSQLND_METHOD(mysqlnd_net, enable_ssl)(MYSQLND_NET * const net TSRMLS_DC)
                ZVAL_STRING(&key_zval, net->data->options.ssl_key, 0);
                php_stream_context_set_option(context, "ssl", "local_pk", &key_zval);
        }
-       if (net->data->options.ssl_verify_peer) {
-               zval verify_peer_zval;
-               ZVAL_TRUE(&verify_peer_zval);
-               php_stream_context_set_option(context, "ssl", "verify_peer", &verify_peer_zval);
-               php_stream_context_set_option(context, "ssl", "verify_peer_name", &verify_peer_zval);
-       } else {
+       {
                zval verify_peer_zval;
-               ZVAL_FALSE(&verify_peer_zval);
+               ZVAL_BOOL(&verify_peer_zval, net->data->options.ssl_verify_peer);
                php_stream_context_set_option(context, "ssl", "verify_peer", &verify_peer_zval);
                php_stream_context_set_option(context, "ssl", "verify_peer_name", &verify_peer_zval);
        }