Navigation Menu

Skip to content

Commit

Permalink
Fixed bug #71003: Add PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT
Browse files Browse the repository at this point in the history
  • Loading branch information
krallin authored and nikic committed Mar 9, 2017
1 parent b224e74 commit 247ce05
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NEWS
Expand Up @@ -13,6 +13,10 @@ PHP NEWS
. Fixed bug #74159 (Writing a large buffer to a non-blocking encrypted stream
fails with "bad write retry"). (trowski)

- PDO MySQL:
. Fixed bug #71003 (Expose MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT to PDO
interface). (Thomas Orozco)

16 Mar 2017 PHP 7.0.17

- Core:
Expand Down
12 changes: 12 additions & 0 deletions ext/pdo_mysql/mysql_driver.c
Expand Up @@ -736,6 +736,18 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options)
}
}
#endif

#ifdef PDO_USE_MYSQLND
{
zend_long ssl_verify_cert = pdo_attr_lval(driver_options,
PDO_MYSQL_ATTR_SSL_VERIFY_SERVER_CERT, -1);
if (ssl_verify_cert != -1) {
connect_opts |= ssl_verify_cert ?
CLIENT_SSL_VERIFY_SERVER_CERT:
CLIENT_SSL_DONT_VERIFY_SERVER_CERT;
}
}
#endif
}

#ifdef PDO_MYSQL_HAS_CHARSET
Expand Down
3 changes: 3 additions & 0 deletions ext/pdo_mysql/pdo_mysql.c
Expand Up @@ -130,6 +130,9 @@ static PHP_MINIT_FUNCTION(pdo_mysql)
REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SERVER_PUBLIC_KEY", (zend_long)PDO_MYSQL_ATTR_SERVER_PUBLIC_KEY);
#endif
REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_MULTI_STATEMENTS", (zend_long)PDO_MYSQL_ATTR_MULTI_STATEMENTS);
#ifdef PDO_USE_MYSQLND
REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_VERIFY_SERVER_CERT", (zend_long)PDO_MYSQL_ATTR_SSL_VERIFY_SERVER_CERT);
#endif

#ifdef PDO_USE_MYSQLND
mysqlnd_reverse_api_register_api(&pdo_mysql_reverse_api);
Expand Down
3 changes: 3 additions & 0 deletions ext/pdo_mysql/php_pdo_mysql_int.h
Expand Up @@ -179,6 +179,9 @@ enum {
PDO_MYSQL_ATTR_SERVER_PUBLIC_KEY,
#endif
PDO_MYSQL_ATTR_MULTI_STATEMENTS,
#ifdef PDO_USE_MYSQLND
PDO_MYSQL_ATTR_SSL_VERIFY_SERVER_CERT,
#endif
};

#endif
1 change: 1 addition & 0 deletions ext/pdo_mysql/tests/pdo_mysql_class_constants.phpt
Expand Up @@ -27,6 +27,7 @@ if (!extension_loaded('mysqli') && !extension_loaded('mysqlnd')) {
"MYSQL_ATTR_SSL_CIPHER" => true,
"MYSQL_ATTR_COMPRESS" => true,
"MYSQL_ATTR_MULTI_STATEMENTS" => true,
"MYSQL_ATTR_SSL_VERIFY_SERVER_CERT" => true,
);

if (!MySQLPDOTest::isPDOMySQLnd()) {
Expand Down

0 comments on commit 247ce05

Please sign in to comment.