{"id":22581,"date":"2023-07-27T13:15:37","date_gmt":"2023-07-27T04:15:37","guid":{"rendered":"https:\/\/labs.gree.jp\/blog\/?p=22581"},"modified":"2023-07-27T16:29:19","modified_gmt":"2023-07-27T07:29:19","slug":"how-to-debug-mysqlnd-so-%ef%bd%9emysql_native_password%e3%81%8c%e5%bb%83%e6%ad%a2%e3%81%95%e3%82%8c%e3%82%8b%e6%9c%aa%e6%9d%a5%e3%81%ab%e5%82%99%e3%81%88%e3%81%a6%ef%bd%9e","status":"publish","type":"post","link":"https:\/\/labs.gree.jp\/blog\/2023\/07\/22581\/","title":{"rendered":"Debugging mysqlnd.so \uff5emysql_native_password\u304c\u5ec3\u6b62\u3055\u308c\u308b\u672a\u6765\u306b\u5099\u3048\u3066\uff5e"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u308f\u3002\u305b\u3058\u307e\u3067\u3059\u3002PHP\u306b\u306f\u758e\u3044\u3093\u3067\u3059\u304c\u3001\u4eca\u56de\u306f\u73cd\u3057\u304fPHP\u306e\u8a71\u3092\u3057\u307e\u3059\u3002<\/p>\n<h2>\u306f\u3058\u3081\u306b<\/h2>\n<p><a href=\"https:\/\/dev.mysql.com\/doc\/relnotes\/mysql\/8.1\/en\/news-8-1-0.html\">2023-07-18 \u306b MySQL 8.1.0 \u304c\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u307e\u3057\u305f\u3002<\/a>\u3044\u304f\u3064\u304b\u6c17\u306b\u306a\u308b\u5909\u66f4\u304c\u5165\u3063\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u4eca\u56de\u306f<\/p>\n<blockquote><p>\n  The mysql_native_password authentication plugin now is deprecated and subject to removal in a future version of MySQL. CREATE USER, ALTER USER, and SET PASSWORD operations now insert a deprecation warning into the server error log if an account attempts to authenticate using mysql_native_password as an authentication method. (Bug #35336317)\n<\/p><\/blockquote>\n<p>\u306b\u95a2\u9023\u3059\u308b\u3068\u3053\u308d\u306b\u3064\u3044\u3066\u3067\u3059\u3002<\/p>\n<p><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/upgrading-from-previous-series.html#upgrade-caching-sha2-password\">MySQL8.0\u3067caching_sha2_password\u304c\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u8a8d\u8a3c\u30d7\u30e9\u30b0\u30a4\u30f3\u306b\u306a\u308a\u307e\u3057\u305f<\/a>\u304c\u30018.0\u304c\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u305f\u5f53\u6642\u3001\u53e4\u3044\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30e9\u30a4\u30d6\u30e9\u30ea\u306fcaching_sha2_password\u306b\u5bfe\u5fdc\u3067\u304d\u3066\u3044\u307e\u305b\u3093\u3067\u3057\u305f\u3002<code>default_authentication_plugin=mysql_native_password<\/code> \u3068\u3044\u3046\u8a2d\u5b9a\u3092\u5165\u308c\u3066MySQL8.0\u3092\u5c0e\u5165\u3055\u308c\u305f\u65b9\u306f\u3001\u5c11\u306a\u304f\u306a\u304b\u3063\u305f\u3067\u3057\u3087\u3046\u3002<br \/>\n\u5c06\u6765\u3001MySQL\u306e\u65b0\u3057\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u3067mysql_native_password\u304c\u5ec3\u6b62\u3055\u308c\u305f\u3068\u304d\u3001\u3053\u3046\u3044\u3063\u305f\u5bfe\u5fdc\u306f\u53d6\u308c\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u306e\u3067\u3001mysql_native_password\u304b\u3089caching_sha2_password\u306b\u79fb\u884c\u3057\u3066\u3044\u304f\u5fc5\u8981\u304c\u767a\u751f\u3057\u307e\u3059\u3002<\/p>\n<h2>caching_sha2_password \u306e\u4ed5\u69d8\u306a\u3069<\/h2>\n<p>caching_sha2_password\u306e\u4ed5\u69d8\u306f\u3001<a href=\"https:\/\/dev.mysql.com\/doc\/dev\/mysql-server\/8.1.0\/page_caching_sha2_authentication_exchanges.html\">Doxygen\u3067\u751f\u6210\u3055\u308c\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a>\u3092\u8aad\u3080\u306e\u304c\u78ba\u5b9f\u3067\u3057\u3087\u3046\u3002<br \/>\ncaching_sha2_password\u306b\u5bfe\u5fdc\u3059\u308b\u3068\u3044\u3046\u3053\u3068\u306f\u3001Fast authentication\u306b\u5bfe\u5fdc\u3059\u308b\u3060\u3051\u3067\u306a\u304f\u3001Complete authentication\u306b\u3069\u306e\u3088\u3046\u306b\u5bfe\u5fdc\u3059\u308b\u304b\u304c\u554f\u984c\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3>Fast authentication<\/h3>\n<p>\u96d1\u306b\u3044\u3044\u307e\u3059\u3068\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306f\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u30cf\u30c3\u30b7\u30e5\uff08\u306eScramble\uff09\u3092\u6700\u521d\u306b\u9001\u4fe1\u3059\u308b\u3093\u3067\u3059\u304c\u3001\u305d\u308c\u304cmysqld\u4e0a\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u306b\u5b58\u5728\u3057\u3066\u3044\u305f\u3089\u305d\u3053\u3067\u8a8d\u8a3c\u7d42\u4e86\u3067\u3001\u305d\u308c\u304cFast authentication\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3>Complete authentication<\/h3>\n<p>\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u30cf\u30c3\u30b7\u30e5\u304cmysqld\u4e0a\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u306b\u5b58\u5728\u3057\u3066\u3044\u306a\u3051\u308c\u3070\u3001<em>\"TCP with TLS OR Socket Or Shared Memory connection\"<\/em>\u3001\u5b89\u5168\u306a\u901a\u4fe1\u7d4c\u8def\u3067\u3042\u308c\u3070\u3001\u305d\u306e\u307e\u307e\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u9001\u4fe1\u3057\u3066\u8a8d\u8a3c\u3057\u307e\u3059\u3002\u5b89\u5168\u306a\u901a\u4fe1\u7d4c\u8def\u3067\u306a\u3051\u308c\u3070\u3001mysqld\u304b\u3089\u516c\u958b\u9375\u3092\u53d6\u5f97\u3057\uff08\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u304c\u3059\u3067\u306b\u516c\u958b\u9375\u3092\u6301\u3063\u3066\u3044\u308b\u306a\u3089\u305d\u308c\u3092\u4f7f\u3044\uff09\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u6697\u53f7\u5316\u3057\u3001mysqld\u3067\u5fa9\u53f7\u5316\u3057\u3066\u8a8d\u8a3c\u3057\u307e\u3059\u3002\u30d1\u30b9\u30ef\u30fc\u30c9\u8a8d\u8a3c\u3067\u304d\u305f\u3089\u3001\u305d\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u30cf\u30c3\u30b7\u30e5\u3092mysqld\u4e0a\u306b\u30ad\u30e3\u30c3\u30b7\u30e5\u3057\u307e\u3059\u3002\u3053\u308c\u304cComplete authentication\u3067\u3059\u3002<\/p>\n<h3>libmysqlclient\u3084\u516c\u5f0f\u306emysql\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u5834\u5408<\/h3>\n<p><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/upgrading-from-previous-series.html#upgrade-caching-sha2-password-compatible-connectors\">mysql \u3084 mysqladmin \u306a\u3069\u306e\u6a19\u6e96 MySQL \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306f libmysqlclient \u30d9\u30fc\u30b9\u3067\u3042\u308b\u305f\u3081<\/a>\u3001\u8a71\u306f\u30b7\u30f3\u30d7\u30eb\u3067\u3059\u3002<\/p>\n<ul>\n<li><a href=\"https:\/\/dev.mysql.com\/doc\/c-api\/8.0\/en\/mysql-options.html\">MYSQL_OPT_SSL_MODE<\/a>\u3084<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/connection-options.html#option_general_ssl-mode\">--ssl-mode<\/a>\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306fPREFERRED\u306a\u306e\u3067\u3001\u7e4b\u3052\u308b\u306a\u3089\u81ea\u52d5\u3067SSL\u3067\u63a5\u7d9a\u3057\u307e\u3059\u3002<\/li>\n<li>ssl-mode=DISABLED\u306a\u5834\u5408\u306f\u3001<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/ja\/caching-sha2-pluggable-authentication.html\">\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306f\u3001\u5fc5\u8981\u306a\u516c\u958b\u30ad\u30fc\u306e\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u30b3\u30d4\u30fc\u3092\u4f7f\u7528\u3059\u308b\u304b\u3001\u30b5\u30fc\u30d0\u30fc\u304b\u3089\u516c\u958b\u30ad\u30fc\u3092\u30ea\u30af\u30a8\u30b9\u30c8\u3067\u304d\u307e\u3059<\/a>\u3002<a href=\"https:\/\/dev.mysql.com\/doc\/c-api\/8.0\/en\/mysql-options.html\">MYSQL_OPT_GET_SERVER_PUBLIC_KEY<\/a>\u3084<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/connection-options.html#option_general_get-server-public-key\">--get-server-public-key<\/a>\u3092\u6307\u5b9a\u3059\u308c\u3070\u3001mysqld\u304b\u3089\u516c\u958b\u9375\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ul>\n<p>\u307b\u3068\u3093\u3069\u306e\u5834\u5408\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067SSL\u7d4c\u7531\u3067\u63a5\u7d9a\u3057\u3001Complete authentication\u306b\u3064\u3044\u3066\u610f\u8b58\u3059\u308b\u3053\u3068\u3082\u306a\u3044\u3067\u3057\u3087\u3046\u3002\u3082\u3057SSL\u3067\u7e4b\u3052\u306a\u3044\u74b0\u5883\u3067\u3082\u3001--get-server-public-key\u3092\u6307\u5b9a\u3059\u308b\u306a\u3069\u3059\u308c\u3070\u826f\u3044\u3060\u3051\u306e\u8a71\u3067\u3059\u3002<\/p>\n<h3>PHP\u306e\u5834\u5408\u306f\uff1f<\/h3>\n<p>MySQL\u306e\u4e2d\u306e\u3072\u3068\u66f0\u304f\u3001<a href=\"https:\/\/blogs.oracle.com\/mysql\/post\/mds-php-and-authentication\">PHP7.4\u306fcaching_sha2_password\u5bfe\u5fdc\u3055\u308c\u3066\u308b<\/a> \u3068\u306e\u3053\u3068\u3067\u3001\u5b9f\u969b\u30017.4.2\u3067<a href=\"https:\/\/github.com\/php\/php-src\/pull\/5034\">Fix caching_sha2_password auth<\/a>\u304cmerge\u3055\u308c\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002<br \/>\n\u306a\u308b\u307b\u3069\u78ba\u304b\u306bcaching_sha2_password\u52d5\u304d\u305d\u3046\u306a\u3093\u3067\u3059\u304c\u3001<a href=\"https:\/\/www.php.net\/manual\/en\/mysqlnd.config.php#ini.mysqlnd.sha256-server-public-key\">mysqlnd\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u898b\u308b\u3068\u3001SHA-256 Authentication Plugin\u306b\u3064\u3044\u3066\u306e\u8a18\u8ff0\u306f\u3042\u308b<\/a>\u3093\u3067\u3059\u304c\u3001--get-server-public-key\u306e\u3088\u3046\u306a\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u898b\u5f53\u305f\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u3069\u306a\u3044\u306a\u3063\u3068\u3093\u306d\u3093\uff1f\uff1f\uff1f<\/p>\n<p>\u3068\u601d\u3063\u305f\u306e\u3067\u3001mysqlnd\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u773a\u3081\u305f\u308a\u3001PHP\u3067\u691c\u8a3c\u3059\u308b\u305f\u3081\u306e\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u305f\u3093\u3067\u3059\u304c\u3001libmysqlclient\u3068\u7570\u306a\u308b\u632f\u308b\u821e\u3044\u3060\u3063\u305f\u306e\u3067\u3001\u78ba\u8a3c\u304c\u6301\u3066\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u305f\u3060\u3001<\/p>\n<p>PHP\u306fOSS\u306a\u3093\u3060\u304b\u3089gdb\u3067breakpoint\u306f\u308c\u3070\u3044\u3044\u304b<\/p>\n<p>\u3068\u601d\u3063\u305f\u306e\u3067\u3001\u30c7\u30d0\u30c3\u30ac\u3067\u691c\u8a3c\u3057\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<br \/>\n\u4eca\u56de\u306f\u304a\u624b\u8efd\u306b\u3001 Ubuntu 20.04 LTS on WSL2\u3067\u691c\u8a3c\u3057\u307e\u3057\u305f\u3002\u4fbf\u5229\u306a\u6642\u4ee3\u306b\u306a\u3063\u305f\u3082\u306e\u3067\u3059\u3002<\/p>\n<h2>\u30c6\u30b9\u30c8\u74b0\u5883\u306eMySQL<\/h2>\n<p>WSL2\u4e0a\u3067\u30c7\u30d0\u30c3\u30b0\u30d3\u30eb\u30c9\u6e08\u307f\u306eMySQL8.0.34\u304c\u3042\u3063\u305f\u306e\u3067\u3001\u305d\u3053\u3067<\/p>\n<pre><code class=\"language-sql\">CREATE USER sejima@'127.0.0.1' IDENTIFIED BY 'sejima';\nGRANT ALL ON *.* TO sejima@'127.0.0.1';\n<\/code><\/pre>\n<p>\u306a\u3069\u3057\u307e\u3057\u305f\u3002<\/p>\n<h2>PHP\u3067Complete authentication\u3092\u691c\u8a3c\u3059\u308b\u305f\u3081\u306e\u30b9\u30af\u30ea\u30d7\u30c8<\/h2>\n<pre class=\"lang:php\"><code><?php\n\nprintf(\"Client library version: %s\\n\", mysqli_get_client_info());\n\n$mysqli = new mysqli('127.0.0.1', 'sejima', 'sejima', 'mysql');\nif ($mysqli->connect_errno) {\n   echo \"Errno: \" . $mysqli->connect_errno . PHP_EOL;\n   echo \"Error: \" . $mysqli->connect_error . PHP_EOL;\n   exit;\n}\n\necho \"PHP\" . phpversion() . PHP_EOL;\n\n$sql = \"SHOW SESSION STATUS LIKE 'Ssl_cipher'\";\nif (!$result = $mysqli->query($sql)) {\n   echo \"Query: \" . $sql . PHP_EOL;\n   echo \"Errno: \" . $mysqli->errno . PHP_EOL;\n   echo \"Error: \" . $mysqli->error . PHP_EOL;\n   exit;\n}\n\n$rows = $result->fetch_all(MYSQLI_NUM);\nforeach ($rows as $row) {\n    printf(\"%s (%s)\\n\", $row[0], $row[1]);\n}\n\n$result->free();\n\n$sql = \"select user, plugin from user where user = 'sejima'\";\nif (!$result = $mysqli->query($sql)) {\n   echo \"Query: \" . $sql . PHP_EOL;\n   echo \"Errno: \" . $mysqli->errno . PHP_EOL;\n   echo \"Error: \" . $mysqli->error . PHP_EOL;\n   exit;\n}\n\n$rows = $result->fetch_all(MYSQLI_NUM);\nforeach ($rows as $row) {\n    printf(\"%s (%s)\\n\", $row[0], $row[1]);\n}\n\n$mysqli->query(\"FLUSH PRIVILEGES\");\n\n$result->free();\n$mysqli->close();\n?><\/code><\/pre>\n<p>\u5b9f\u884c\u4f8b\u306f\u6b21\u306e\u3088\u3046\u306a\u3082\u306e\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code>sejima:~$ php test.php\nClient library version: mysqlnd 7.4.3-4ubuntu2.19\nPHP7.4.3-4ubuntu2.19\nSsl_cipher ()\nsejima (caching_sha2_password)\nsejima:~$\n<\/code><\/pre>\n<p>\u7d30\u304b\u3044\u3068\u3053\u308d\u3092\u88dc\u8db3\u3057\u307e\u3059\u3002<\/p>\n<h3>127.0.0.1<\/h3>\n<p><a href=\"https:\/\/www.php.net\/manual\/en\/mysqli.quickstart.connections.php\">\u3053\u3053\u3092localhost\u306b\u3059\u308b\u3068 socket file \u7d4c\u7531\u306e\u63a5\u7d9a\u306b\u306a\u308a<\/a>\u3001\u5b89\u5168\u306a\u901a\u4fe1\u7d4c\u8def\u3068\u307f\u306a\u3055\u308c\u3066\u3057\u307e\u3044\u3001\u516c\u958b\u9375\u3092\u53d6\u5f97\u3059\u308b\u53ef\u80fd\u6027\u304c\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<h3>SHOW SESSION STATUS LIKE 'Ssl_cipher';<\/h3>\n<p><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/server-status-variables.html#statvar_Ssl_cipher\">SSL\u7d4c\u7531\u3067\u3042\u308c\u3070TLS_AES_256_GCM_SHA384\u306e\u3088\u3046\u306a\u5024\u304c\u3001SSL\u7d4c\u7531\u3067\u306a\u3051\u308c\u3070empty\u304c\u8fd4\u3063\u3066\u304d\u307e\u3059<\/a>\u3002\u3053\u308c\u306b\u3088\u308a\u3001SSL\u7d4c\u7531\u3067\u63a5\u7d9a\u3055\u308c\u3066\u3044\u308b\u304b\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code>sejima:~\/src\/mysql\/mysql-8.0.34\/bld$ bin\/mysql -u root -h 127.0.0.1 -p\nEnter password:\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 76\nServer version: 8.0.34-debug Source distribution\n\nCopyright (c) 2000, 2023, Oracle and\/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and\/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql> SHOW SESSION STATUS LIKE 'Ssl_cipher';\n+---------------+------------------------+\n| Variable_name | Value                  |\n+---------------+------------------------+\n| Ssl_cipher    | TLS_AES_256_GCM_SHA384 |\n+---------------+------------------------+\n1 row in set (0.01 sec)\n\nmysql> exit\nBye\nsejima:~\/src\/mysql\/mysql-8.0.34\/bld$ bin\/mysql -u root -h localhost -p\nEnter password:\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 77\nServer version: 8.0.34-debug Source distribution\n\nCopyright (c) 2000, 2023, Oracle and\/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and\/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql> SHOW SESSION STATUS LIKE 'Ssl_cipher';\n+---------------+-------+\n| Variable_name | Value |\n+---------------+-------+\n| Ssl_cipher    |       |\n+---------------+-------+\n1 row in set (0.01 sec)\n\nmysql> exit\nBye\nsejima:~\/src\/mysql\/mysql-8.0.34\/bld$<\/code><\/pre>\n<h3>FLUSH PRIVILEGES<\/h3>\n<p><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/flush.html#flush-privileges\">mysqld\u4e0a\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u30cf\u30c3\u30b7\u30e5\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u30af\u30ea\u30a2\u3055\u308c\u307e\u3059<\/a>\u3002\u6b21\u56de\u63a5\u7d9a\u6642\u3001Complete authentication\u3092\u5f37\u5236\u3059\u308b\u305f\u3081\u306e\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\u306e\u51e6\u7406\u3068\u3057\u3066\u5165\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>mysqlnd\u304c\u516c\u958b\u9375\u3092\u53d6\u5f97\u3057\u3066\u3044\u308b\u3068\u3053\u308d\u3092gdb\u3067\u78ba\u8a8d\u3059\u308b<\/h2>\n<p>\u4e0a\u8a18\u306e\u691c\u8a3c\u7528\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c\u3057\u305f\u3089Ssl_cipher\u304c\u7a7a\u3060\u3063\u305f\u306e\u3067\u3001SSL\u7d4c\u7531\u3058\u3083\u306a\u3044\u3093\u3060\u308d\u3046\u3068\u601d\u3046\u308f\u3051\u3067\u3059\u304c\u3001\u516c\u958b\u9375\u3092\u53d6\u5f97\u3057\u3066\u3044\u308b\u305d\u306e\u77ac\u9593\u3092\u78ba\u8a8d\u3057\u305f\u3044\u308f\u3051\u3067\u3059\u3002\u3068\u3044\u3046\u308f\u3051\u3067\u3001Debug Symbol Package\u306a\u3069\u3092\u5165\u308c\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h3>PHP\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<pre><code>$ sudo apt install php7.4-cli php7.4-mysql\n<\/code><\/pre>\n<h3>PHP\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>\/etc\/apt\/sources.list \u3067deb-src\u304c\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3055\u308c\u3066\u3044\u308b\u3088\u3046\u3067\u3042\u308c\u3070\u3001\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3092\u7121\u52b9\u5316\u3057\u3066<\/p>\n<pre><code>$ sudo apt-get update\n<\/code><\/pre>\n<p>\u3057\u3066<\/p>\n<pre><code>$ apt-get source php7.4-cli php7.4-mysql\n<\/code><\/pre>\n<p>\u3057\u307e\u3059\u3002<\/p>\n<h3>Debug Symbol Packages<\/h3>\n<p>Ubuntu\u516c\u5f0f\u306e <a href=\"https:\/\/wiki.ubuntu.com\/Debug%20Symbol%20Packages\">Debug Symbol Packages<\/a> \u3092\u53c2\u8003\u306b\u3084\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<pre><code>echo \"deb http:\/\/ddebs.ubuntu.com $(lsb_release -cs) main restricted universe multiverse\ndeb http:\/\/ddebs.ubuntu.com $(lsb_release -cs)-updates main restricted universe multiverse\ndeb http:\/\/ddebs.ubuntu.com $(lsb_release -cs)-proposed main restricted universe multiverse\" | \\\nsudo tee -a \/etc\/apt\/sources.list.d\/ddebs.list\n<\/code><\/pre>\n<pre><code>sudo apt install ubuntu-dbgsym-keyring\n<\/code><\/pre>\n<pre><code>sudo apt-get update\n<\/code><\/pre>\n<p>\u3042\u3068\u306f<\/p>\n<pre><code>sudo apt install php7.4-cli-dbgsym php7.4-mysql-dbgsym\n<\/code><\/pre>\n<p>\u3057\u307e\u3059\u3002<\/p>\n<h3>\u516c\u958b\u9375\u30d5\u30a1\u30a4\u30eb\u306e\u78ba\u8a8d<\/h3>\n<p><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/server-system-variables.html#sysvar_caching_sha2_password_auto_generate_rsa_keys\">caching_sha2_password_auto_generate_rsa_keys<\/a>\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067ON\u3067\u3001<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/server-system-variables.html#sysvar_caching_sha2_password_public_key_path\">caching_sha2_password_public_key_path<\/a>\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306fpublic_key.pem\u306a\u306e\u3067\u3001<\/p>\n<pre><code>mysql> select @@datadir;\n+-----------------------------------------------+\n| @@datadir                                     |\n+-----------------------------------------------+\n| \/home\/sejima\/src\/mysql\/mysql-8.0.34\/bld\/data\/ |\n+-----------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql><\/code><\/pre>\n<p>\u306a\u74b0\u5883\u3067\u3042\u308c\u3070<\/p>\n<pre><code>sejima:~\/src\/mysql\/mysql-8.0.34\/bld$ cat data\/public_key.pem\n-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArLGxm1WIOs1MJJxqcrcH\nU0RKPeIMu\/\/K070VNgQof\/iWH8NL+yU4q90pS9mEtWnwXr0gTbhkfJZkvJB3dNpz\nVJRQJPv2gN81pQ\/94poRe6lH+GNL5+5nEN6SMiLM2fpM4OgLdM+oPs\/Ko2UroUug\ncKnhRswIcZ72w2puYujpdZZ3ffiIaM522gT6O0K10eFwvCu2FdiK9Elkb\/qYJ9Ay\n4IRZD8NVDOgkamqIZ2JzIJBYV6NMhDOncq2xM6yY0va0ufredSdlWnT7bBHfzMNN\nvj4xacmO++abgXsnN+68uXOA5E0Igig7MP8UrGku9F8I0dcRLzdWwXsE41TUApfu\ncQIDAQAB\n-----END PUBLIC KEY-----\nsejima:~\/src\/mysql\/mysql-8.0.34\/bld$\n<\/code><\/pre>\n<p>\u3068\u3044\u3046\u3088\u3046\u306b\u914d\u7f6e\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>gdb\u3067breakpoint\u5f35\u3063\u3066\u691c\u8a3c\u7528\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c<\/h3>\n<p>apt-get source \u3057\u3066 ~\/php7.4-7.4.3 \u3068\u304b\u306b\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u304c\u5c55\u958b\u3055\u308c\u3066\u308b\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001<\/p>\n<pre><code>$ cd ~\/php7.4-7.4.3\n$ gdb \/usr\/bin\/php\n<\/code><\/pre>\n<p>\u3057\u307e\u3059\u3002\u3082\u3057\u4e07\u304c\u4e00gdb\u304c\u5165\u3063\u3066\u306a\u304b\u3063\u305f\u3089\u3001sudo apt install gdb\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3068\u308a\u3042\u3048\u305a\u3001<br \/>\n<a href=\"https:\/\/github.com\/php\/php-src\/blob\/php-7.4.3\/ext\/mysqlnd\/mysqlnd_auth.c#L1112\">https:\/\/github.com\/php\/php-src\/blob\/php-7.4.3\/ext\/mysqlnd\/mysqlnd_auth.c#L1112<\/a><br \/>\n\u3068<br \/>\n<a href=\"https:\/\/github.com\/php\/php-src\/blob\/php-7.4.3\/ext\/mysqlnd\/mysqlnd_auth.c#L978\">https:\/\/github.com\/php\/php-src\/blob\/php-7.4.3\/ext\/mysqlnd\/mysqlnd_auth.c#L978<\/a><br \/>\n\u3042\u305f\u308a\u306bbreakpoint\u306f\u3063\u3066\u3001mysqlnd_auth.c:978\u3067\u6b62\u307e\u3063\u305f\u3089<\/p>\n<pre><code>(gdb) p pk_resp_packet.public_key\n<\/code><\/pre>\n<p>\u3057\u3066\u3001\u3055\u304d\u307b\u3069\u306e\u516c\u958b\u9375\u304c\u6765\u3066\u308b\u304b\u3069\u3046\u304b\u78ba\u8a8d\u3059\u308c\u3070\u826f\u3044\u3093\u3058\u3083\u306a\u3044\u304b\u3001\u3068\u3044\u3046\u3068\u3053\u308d\u3067\u3059\u3002\u3068\u3044\u3046\u308f\u3051\u3067<\/p>\n<pre><code>sejima:~\/php7.4-7.4.3$ gdb \/usr\/bin\/php\nGNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2\nCopyright (C) 2020 Free Software Foundation, Inc.\nLicense GPLv3+: GNU GPL version 3 or later <http:\/\/gnu.org\/licenses\/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\nType \"show copying\" and \"show warranty\" for details.\nThis GDB was configured as \"x86_64-linux-gnu\".\nType \"show configuration\" for configuration details.\nFor bug reporting instructions, please see:\n<http:\/\/www.gnu.org\/software\/gdb\/bugs\/>.\nFind the GDB manual and other documentation resources online at:\n    <http:\/\/www.gnu.org\/software\/gdb\/documentation\/>.\n\nFor help, type \"help\".\nType \"apropos word\" to search for commands related to \"word\"...\nReading symbols from \/usr\/bin\/php...\nReading symbols from \/usr\/lib\/debug\/.build-id\/8b\/320de7b512fa926aec4ec48d08bdb2e99251a2.debug...\nwarning: File \"\/home\/sejima\/php7.4-7.4.3\/.gdbinit\" auto-loading has been declined by your `auto-load safe-path' set to \"$debugdir:$datadir\/auto-load\".\nTo enable execution of this file add\n        add-auto-load-safe-path \/home\/sejima\/php7.4-7.4.3\/.gdbinit\nline to your configuration file \"\/home\/sejima\/.gdbinit\".\nTo completely disable this security protection add\n        set auto-load safe-path \/\nline to your configuration file \"\/home\/sejima\/.gdbinit\".\nFor more information about this security protection see the\n\"Auto-loading safe path\" section in the GDB manual.  E.g., run from the shell:\n        info \"(gdb)Auto-loading safe path\"\n(gdb) info share\nNo shared libraries loaded at this time.\n(gdb) b mysqlnd_auth.c:1112\nNo source file named mysqlnd_auth.c.\nMake breakpoint pending on future shared library load? (y or [n]) y\nBreakpoint 1 (mysqlnd_auth.c:1112) pending.\n(gdb) b mysqlnd_auth.c:978\nNo source file named mysqlnd_auth.c.\nMake breakpoint pending on future shared library load? (y or [n]) y\nBreakpoint 2 (mysqlnd_auth.c:978) pending.\n(gdb) info break\nNum     Type           Disp Enb Address    What\n1       breakpoint     keep y   <PENDING>  mysqlnd_auth.c:1112\n2       breakpoint     keep y   <PENDING>  mysqlnd_auth.c:978\n(gdb)<\/code><\/pre>\n<p>\u3068\u3044\u3046\u611f\u3058\u3067\u3059\u3002<br \/>\n\u3061\u306a\u307f\u306b\u3001\u3053\u3053\u304c\u4eca\u56de\u306e\u30dd\u30a4\u30f3\u30c8\u3067\u3059\u3002info share\u3067 'No shared libraries loaded at this time.' \u3067\u3001 info break \u3067 Address \u304c &lt;PENDING&gt; \u306b\u306a\u3063\u3066\u304a\u308a\u3001 mysqlnd.so \u306f\u307e\u3060\u30ed\u30fc\u30c9\u3055\u308c\u3066\u3044\u306a\u3044\u72b6\u614b\u3067\u3059\u3002 rbreak mysqlnd_caching_sha2_get_key \u3068\u304b\u3084\u3063\u3066\u3082\u3053\u306e\u6bb5\u968e\u3067\u306f\u5f35\u308c\u307e\u305b\u3093\u3002gdb\u306f\u8ce2\u3044\u306e\u3067\u3001mysqlnd.so\u304c\u30ed\u30fc\u30c9\u3055\u308c\u308b\u3068breakpoint\u3067\u6b62\u307e\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\uff08\u672c\u5f53\u306fvscode\u3067\u3084\u308c\u308c\u3070\u3088\u304b\u3063\u305f\u3093\u3067\u3059\u304c\u3001vscode\u529b\u304c\u4f4e\u3044\u304a\u3063\u3055\u3093\u306a\u306e\u3067\u3001\u4eca\u56de\u306f\u624b\u3063\u53d6\u308a\u65e9\u304fgdb\u306eCLI\u3067\u3084\u308a\u307e\u3057\u305f\u3002\u4eca\u5f8c\u306e\u8ab2\u984c\u306b\u3057\u305f\u3044\u306a\u3068\u601d\u3044\u307e\u3059\u3002\uff09<\/p>\n<p>\u3067\u3001 run \/home\/sejma\/test.php \u306a\u3069\u3084\u308a\u307e\u3059\u3068<\/p>\n<pre><code>(gdb) run \/home\/sejima\/test.php\nStarting program: \/usr\/bin\/php \/home\/sejima\/test.php\n[Thread debugging using libthread_db enabled]\nUsing host libthread_db library \"\/lib\/x86_64-linux-gnu\/libthread_db.so.1\".\nClient library version: mysqlnd 7.4.3-4ubuntu2.19\n\nBreakpoint 1, mysqlnd_caching_sha2_get_key (conn=0x7ffff5475000) at .\/ext\/mysqlnd\/mysqlnd_auth.c:1112\n1112 result_packet.password_len = mysqlnd_caching_sha2_get_and_use_key(conn, auth_plugin_data, auth_plugin_data_len, &amp;result_packet.password, passwd, passwd_len);\n(gdb) c\nContinuing.\n\nBreakpoint 2, mysqlnd_caching_sha2_get_key (conn=0x7ffff5475000) at .\/ext\/mysqlnd\/mysqlnd_auth.c:978\n978 BIO_free(bio);\n(gdb) p pk_resp_packet.public_key\n$2 = (zend_uchar *) 0x7ffff5491200 \"-----BEGIN PUBLIC KEY-----\\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArLGxm1WIOs1MJJxqcrcH\\nU0RKPeIMu\/\/K070VNgQof\/iWH8NL+yU4q90pS9mEtWnwXr0gTbhkfJZkvJB3dNpz\\nVJRQJPv2gN81pQ\/94poRe6lH+GNL5+5nEN6SMiLM2fp\"...\n(gdb) c\nContinuing.\nPHP7.4.3-4ubuntu2.19\nSsl_cipher ()\nsejima (caching_sha2_password)\nwarning: Temporarily disabling breakpoints for unloaded shared library \"\/usr\/lib\/php\/20190902\/mysqlnd.so\"\n[Inferior 1 (process 10840) exited normally]\n(gdb)\n<\/code><\/pre>\n<p>\u3055\u304d\u307b\u3069\u306e\u516c\u958b\u9375\u3092\u53d6\u5f97\u3057\u3066\u3044\u308b\u3068\u3053\u308d\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\u3002\u3053\u308c\u306f p pk_resp_packet.public_key \u3057\u3066\u304b\u3089\u8fc5\u901f\u306b c \u3057\u3066\u3044\u308b\u306e\u3067\u3001\u6b63\u5e38\u7d42\u4e86\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u3086\u3063\u304f\u308a\u3084\u308b\u3068<\/p>\n<pre><code>(gdb) run \/home\/sejima\/test.php\nStarting program: \/usr\/bin\/php \/home\/sejima\/test.php\n[Thread debugging using libthread_db enabled]\nUsing host libthread_db library \"\/lib\/x86_64-linux-gnu\/libthread_db.so.1\".\nClient library version: mysqlnd 7.4.3-4ubuntu2.19\n\nBreakpoint 1, mysqlnd_caching_sha2_get_key (conn=0x7ffff5475000) at .\/ext\/mysqlnd\/mysqlnd_auth.c:1112\n1112                                    result_packet.password_len = mysqlnd_caching_sha2_get_and_use_key(conn, auth_plugin_data, auth_plugin_data_len, &result_packet.password, passwd, passwd_len);\n(gdb) c\nContinuing.\n\nBreakpoint 2, mysqlnd_caching_sha2_get_key (conn=0x7ffff5475000) at .\/ext\/mysqlnd\/mysqlnd_auth.c:978\n978                                     BIO_free(bio);\n(gdb) p pk_resp_packet.public_key\n$1 = (zend_uchar *) 0x7ffff5491200 \"-----BEGIN PUBLIC KEY-----\\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArLGxm1WIOs1MJJxqcrcH\\nU0RKPeIMu\/\/K070VNgQof\/iWH8NL+yU4q90pS9mEtWnwXr0gTbhkfJZkvJB3dNpz\\nVJRQJPv2gN81pQ\/94poRe6lH+GNL5+5nEN6SMiLM2fp\"...\n(gdb) c\nContinuing.\nPHP Warning:  Packets out of order. Expected 6 received 5. Packet size=50 in \/home\/sejima\/test.php on line 5\nPHP Warning:  mysqli::__construct(): (HY000\/2006): MySQL server has gone away in \/home\/sejima\/test.php on line 5\nErrno: 2006\nError: MySQL server has gone away\nwarning: Temporarily disabling breakpoints for unloaded shared library \"\/usr\/lib\/php\/20190902\/mysqlnd.so\"\n[Inferior 1 (process 10836) exited normally]\n(gdb)<\/code><\/pre>\n<p>\u3068\u306a\u308a\u307e\u3059\u3002\u5185\u90e8\u7684\u306a\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u3068\u304b\u306b\u5f15\u3063\u304b\u304b\u308b\u304b\u3001\u306a\u3093\u3089\u304b\u306e timing issue \u306a\u6c17\u304c\u3057\u307e\u3059\u304c\u3001\u4eca\u56de\u306e\u4e3b\u984c\u304b\u3089\u5916\u308c\u308b\u306e\u3067\u3001\u3044\u3063\u305f\u3093\u5fd8\u308c\u307e\u3059\u3002<\/p>\n<p>\u305b\u3063\u304b\u304f\u306a\u306e\u3067\u3001Breakpoint 1\u3067\u6b62\u307e\u3063\u3066\u308b\u3068\u304d\u306e info share \u3084 info break \u306a\u3069\u3082\u63b2\u8f09\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<pre><code>(gdb) run \/home\/sejima\/test.php\nStarting program: \/usr\/bin\/php \/home\/sejima\/test.php\n[Thread debugging using libthread_db enabled]\nUsing host libthread_db library \"\/lib\/x86_64-linux-gnu\/libthread_db.so.1\".\nClient library version: mysqlnd 7.4.3-4ubuntu2.19\n\nBreakpoint 1, mysqlnd_caching_sha2_get_key (conn=0x7ffff5475000) at .\/ext\/mysqlnd\/mysqlnd_auth.c:1112\n1112                                    result_packet.password_len = mysqlnd_caching_sha2_get_and_use_key(conn, auth_plugin_data, auth_plugin_data_len, &result_packet.password, passwd, passwd_len);\n(gdb) info break\nNum     Type           Disp Enb Address            What\n1       breakpoint     keep y   0x00007ffff50f71c0 in mysqlnd_caching_sha2_get_key at .\/ext\/mysqlnd\/mysqlnd_auth.c:1112\n        breakpoint already hit 1 time\n2       breakpoint     keep y   0x00007ffff50f75a1 in mysqlnd_caching_sha2_get_key at .\/ext\/mysqlnd\/mysqlnd_auth.c:978\n(gdb) info share\nFrom                To                  Syms Read   Shared Object Library\n0x00007ffff7fd0100  0x00007ffff7ff2684  Yes         \/lib64\/ld-linux-x86-64.so.2\n0x00007ffff7fb4110  0x00007ffff7fb8997  Yes (*)     \/lib\/x86_64-linux-gnu\/libargon2.so.1\n0x00007ffff7f9b720  0x00007ffff7faa11c  Yes         \/lib\/x86_64-linux-gnu\/libresolv.so.2\n0x00007ffff7e553c0  0x00007ffff7efbfa8  Yes         \/lib\/x86_64-linux-gnu\/libm.so.6\n0x00007ffff7e43220  0x00007ffff7e44179  Yes         \/lib\/x86_64-linux-gnu\/libdl.so.2\n0x00007ffff7cb5e50  0x00007ffff7ddeb8e  Yes (*)     \/lib\/x86_64-linux-gnu\/libxml2.so.2\n0x00007ffff7c14770  0x00007ffff7c5fbaa  Yes (*)     \/lib\/x86_64-linux-gnu\/libssl.so.1.1\n0x00007ffff7996000  0x00007ffff7b2ff10  Yes (*)     \/lib\/x86_64-linux-gnu\/libcrypto.so.1.1\n0x00007ffff788e2e0  0x00007ffff78f234e  Yes (*)     \/lib\/x86_64-linux-gnu\/libpcre2-8.so.0\n0x00007ffff7872280  0x00007ffff7882f9b  Yes (*)     \/lib\/x86_64-linux-gnu\/libz.so.1\n0x00007ffff7824280  0x00007ffff785bd89  Yes (*)     \/lib\/x86_64-linux-gnu\/libsodium.so.23\n0x00007ffff7648630  0x00007ffff77bd27d  Yes         \/lib\/x86_64-linux-gnu\/libc.so.6\n0x00007ffff7609ae0  0x00007ffff7619535  Yes         \/lib\/x86_64-linux-gnu\/libpthread.so.0\n0x00007ffff7480920  0x00007ffff7564967  Yes (*)     \/lib\/x86_64-linux-gnu\/libicuuc.so.66\n0x00007ffff73f53c0  0x00007ffff740c3b6  Yes (*)     \/lib\/x86_64-linux-gnu\/liblzma.so.5\n0x00007ffff5932040  0x00007ffff59320f9  Yes (*)     \/lib\/x86_64-linux-gnu\/libicudata.so.66\n0x00007ffff57ed160  0x00007ffff58d5452  Yes (*)     \/lib\/x86_64-linux-gnu\/libstdc++.so.6\n0x00007ffff57375e0  0x00007ffff5748045  Yes (*)     \/lib\/x86_64-linux-gnu\/libgcc_s.so.1\n0x00007ffff5658fc0  0x00007ffff56b4868  Yes (*)     \/usr\/lib\/php\/20190902\/opcache.so\n0x00007ffff5637720  0x00007ffff563ad70  Yes         \/lib\/x86_64-linux-gnu\/librt.so.1\n0x00007ffff50e6f10  0x00007ffff51050fe  Yes         \/usr\/lib\/php\/20190902\/mysqlnd.so\n0x00007ffff561f200  0x00007ffff562ae92  Yes (*)     \/usr\/lib\/php\/20190902\/pdo.so\n0x00007ffff560f360  0x00007ffff561201e  Yes (*)     \/usr\/lib\/php\/20190902\/calendar.so\n0x00007ffff56450e0  0x00007ffff5645bac  Yes (*)     \/usr\/lib\/php\/20190902\/ctype.so\n0x00007ffff50c7920  0x00007ffff50cda9c  Yes (*)     \/usr\/lib\/php\/20190902\/exif.so\n0x00007ffff509bb20  0x00007ffff50b4ac6  Yes (*)     \/usr\/lib\/php\/20190902\/ffi.so\n0x00007ffff508d230  0x00007ffff5092a46  Yes (*)     \/lib\/x86_64-linux-gnu\/libffi.so.7\n0x00007ffff4b13de0  0x00007ffff4b25b29  Yes (*)     \/usr\/lib\/php\/20190902\/fileinfo.so\n0x00007ffff4b01bc0  0x00007ffff4b0874a  Yes (*)     \/usr\/lib\/php\/20190902\/ftp.so\n0x00007ffff56072c0  0x00007ffff560809c  Yes (*)     \/usr\/lib\/php\/20190902\/gettext.so\n0x00007ffff4af2920  0x00007ffff4af7ddd  Yes (*)     \/usr\/lib\/php\/20190902\/iconv.so\n0x00007ffff4ae45a0  0x00007ffff4aea837  Yes (*)     \/usr\/lib\/php\/20190902\/json.so\n0x00007ffff4ac5d80  0x00007ffff4ad57a0  Yes         \/usr\/lib\/php\/20190902\/mysqli.so\n--Type <RET> for more, q to quit, c to continue without paging--q\nQuit\n(gdb) c\nContinuing.\n\nBreakpoint 2, mysqlnd_caching_sha2_get_key (conn=0x7ffff5475000) at .\/ext\/mysqlnd\/mysqlnd_auth.c:978\n978                                     BIO_free(bio);\n(gdb) c\nContinuing.\nPHP7.4.3-4ubuntu2.19\nSsl_cipher ()\nsejima (caching_sha2_password)\nwarning: Temporarily disabling breakpoints for unloaded shared library \"\/usr\/lib\/php\/20190902\/mysqlnd.so\"\n[Inferior 1 (process 10842) exited normally]\n(gdb)<\/code><\/pre>\n<p>\u3068\u3044\u3046\u3088\u3046\u306b\u3001Address\u306f\u89e3\u6c7a\u3055\u308c\u3001\/usr\/lib\/php\/20190902\/mysqlnd.so\u304c\u30ed\u30fc\u30c9\u3055\u308c\u3066\u3044\u308b\u306e\u3082\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002mysqlnd.so\u304c\u30a2\u30f3\u30ed\u30fc\u30c9\u3055\u308c\u308b\u3068\u3001breakpoint\u304c\u7121\u52b9\u5316\u3055\u308c\u308b\u306e\u3082\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u78ba\u8a8d\u3067\u304d\u305f mysqlnd \u306e caching_sha2_password \u306e\u632f\u308b\u821e\u3044<\/h2>\n<p><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/caching-sha2-pluggable-authentication.html\">MySQL\u306e\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a>\u306b\u306f<\/p>\n<blockquote><p>\n  For connections by accounts that authenticate with caching_sha2_password and RSA key pair-based password exchange, the server does not send the RSA public key to clients by default.\n<\/p><\/blockquote>\n<p>\u3068\u3042\u308b\u306e\u3067\u3001Complete authentication\u306b\u516c\u958b\u9375\u3092\u7528\u3044\u308b\u306e\u306f\u3001\u3042\u304f\u307e\u3067\u30aa\u30d7\u30b7\u30e7\u30f3\u6271\u3044\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u5b9f\u969b\u3001libmysqlclient\u3092\u4f7f\u3063\u305f\u516c\u5f0f\u306emysql\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306f\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306fSSL\u3067\u63a5\u7d9a\u3057\u3066Complete authentication\u3092\u884c\u3044\u307e\u3059\u3002<br \/>\n\u4e00\u65b9\u3001\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u306f<\/p>\n<blockquote><p>\n  RSA-based password exchange is available regardless of the SSL library against which MySQL is linked.\n<\/p><\/blockquote>\n<p>\u3068\u3082\u3042\u308a\u307e\u3059\u3002\uff08\u3053\u306e\u3042\u305f\u308a\u306e\u7d4c\u7def\u306f\u77e5\u308a\u307e\u305b\u3093\u304c\uff09\u3082\u3057\u304b\u3059\u308b\u3068mysqlnd\u958b\u767a\u8005\u306f\u3001SSL\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3078\u306e\u4f9d\u5b58\u5ea6\u3092\u4e0b\u3052\u308b\u3079\u304f\u3001\u516c\u958b\u9375\u3092\u7528\u3044\u3066Complete authentication\u3059\u308b\u3088\u3046\u306b\u5b9f\u88c5\u3057\u305f\u306e\u3067\u3057\u3087\u3046\u304b\uff1f<\/p>\n<p>\u305b\u3063\u304b\u304f\u306a\u306e\u3067\u3001<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/server-system-variables.html#sysvar_require_secure_transport\">require_secure_transport<\/a>\u3092\u6709\u52b9\u306b\u3057\u3066\u3001\u5148\u7a0b\u306e\u691c\u8a3c\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><code>sejima:~\/src\/mysql\/mysql-8.0.34\/bld$ .\/bin\/mysql -u root -p\nEnter password:\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 90\nServer version: 8.0.34-debug Source distribution\n\nCopyright (c) 2000, 2023, Oracle and\/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and\/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql> select @@require_secure_transport;\n+----------------------------+\n| @@require_secure_transport |\n+----------------------------+\n|                          0 |\n+----------------------------+\n1 row in set (0.00 sec)\n\nmysql> set global require_secure_transport=on;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@require_secure_transport;\n+----------------------------+\n| @@require_secure_transport |\n+----------------------------+\n|                          1 |\n+----------------------------+\n1 row in set (0.00 sec)\n\nmysql> exit\nBye\nsejima:~\/src\/mysql\/mysql-8.0.34\/bld$ php ~\/test.php\nClient library version: mysqlnd 7.4.3-4ubuntu2.19\nPHP Warning:  mysqli::__construct(): (HY000\/3159): Connections using insecure transport are prohibited while --require_secure_transport=ON. in \/home\/sejima\/test.php on line 5\nErrno: 3159\nError: Connections using insecure transport are prohibited while --require_secure_transport=ON.\nsejima:~\/src\/mysql\/mysql-8.0.34\/bld$<\/code><\/pre>\n<p>\u30b3\u30b1\u307e\u3057\u305f\u3002<br \/>\nPHP 7.4.3-4ubuntu2.19 \u3067 mysqlnd \u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306f --ssl-mode=PREFERRED\u3067\u306f\u306a\u304f\u3001--ssl-mode=DISABLED --get-server-public-key \u76f8\u5f53\u306a\u3093\u3060\u308d\u3046\u306a\u3068\u3044\u3046\u306e\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<h2>\u304a\u308f\u308a\u306b<\/h2>\n<p>\u5c11\u3057\u8abf\u3079\u3066\u307f\u305f\u306e\u3067\u3059\u304c\u3001<\/p>\n<ul>\n<li>mysqlnd\u304ccaching_sha2_password\u306eComplete authentication\u306b\u5bfe\u3057\u3066\u3001\u3069\u306e\u3088\u3046\u306b\u632f\u308b\u821e\u3063\u3066\u3044\u308b\u306e\u304b<\/li>\n<li>mysqlnd\u3092gdb\u3067\u30c7\u30d0\u30c3\u30b0\u3059\u308b<\/li>\n<\/ul>\n<p>\u3068\u3044\u3063\u305f\u8a71\u304c\u3001\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u4e0a\u306b\u3042\u307e\u308a\u8ee2\u304c\u3063\u3066\u306a\u3055\u305d\u3046\u3060\u3063\u305f\u306e\u3067\u3001\u5c11\u3005\u96e3\u5100\u3057\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u3068\u308a\u3042\u3048\u305a\u30c7\u30d0\u30c3\u30ac\u3067\u52d5\u304b\u305b\u3070\u826f\u3044\u3093\u3060\u304b\u3089OSS\u6700\u9ad8\u3067\u3059\u306d\u3068\u6539\u3081\u3066\u518d\u8a8d\u8b58\u3057\u307e\u3057\u305f\u3002\u3082\u3057\u4e07\u304c\u4e00\u3001PHP\u3067caching_sha2_password\u4f7f\u3046\u305f\u3081\u306b\u3001\u516c\u958b\u9375\u306e\u30d5\u30a1\u30a4\u30eb\u3084SSL\u901a\u4fe1\u3059\u308b\u305f\u3081\u306e\u8a3c\u660e\u66f8\u306e\u30d5\u30a1\u30a4\u30eb\u3092mysqlnd\u306b\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u6e21\u3059\u306e\u304c\u5fc5\u9808\u306b\u306a\u308b\u306a\u3089\u3001caching_sha2_password\u306b\u79fb\u884c\u3059\u308b\u30cf\u30fc\u30c9\u30eb\u4e0a\u304c\u308b\u306e\u3067\u306f\u3068\u5371\u60e7\u3057\u3066\u3044\u307e\u3057\u305f\u3002\u3057\u304b\u3057\u3001\u305d\u308c\u306f\u3069\u3046\u3084\u3089\u675e\u6182\u306b\u7d42\u308f\u308a\u305d\u3046\u3067\u30db\u30c3\u3068\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30c7\u30d0\u30c3\u30ac\u3068\u8a00\u3044\u307e\u3059\u3068\u3001MySQL 8.1.0\u30848.0.34\u3067\u3001\u30d3\u30eb\u30c9\u5468\u308a\u306b\u307e\u305f\u5909\u66f4\u304c\u5165\u308a\u307e\u3057\u305f\u3002macOS\u3084Windows\u3067\u306f\u30018.0.33\u3068\u540c\u3058\u3088\u3046\u306b\u306f\u30d3\u30eb\u30c9\u3067\u304d\u306a\u3044\u5834\u5408\u304c\u3042\u308a\u305d\u3046\u306a\u306e\u3067\u3001MySQL 8.1.0\u3092Windows\/macOS\/WSL2\u3067\u30c7\u30d0\u30c3\u30b0\u30d3\u30eb\u30c9\u3059\u308b\u8a71\u306b\u3064\u3044\u3066\u3001\u8fd1\u65e5\u4e2d\u306b\u307e\u305f\u66f8\u3053\u3046\u304b\u306a\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>Special Thanks<\/h2>\n<p>\u4eca\u56de\u3001MYSQL_OPT_SSL_MODE\u306eSSL_MODE_PREFERRED\u3084MYSQL_OPT_GET_SERVER_PUBLIC_KEY\u7684\u306a\u3082\u306e\u304cPHP\u5074\u306b\u306a\u3055\u305d\u3046\u3060\u3068\u5606\u3044\u3066\u3044\u305f\u3089\u3001<a href=\"https:\/\/twitter.com\/yoku0825\/status\/1682005448873103360\">yoku0825\u3055\u3093\u66f0\u304f\u300c\uff08sha256_password\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u65b9\u306b\u306f\uff09\u3042\u308a\u305d\u3046\u306a\u6c17\u304c\u3057\u307e\u3059\u30fc\u300d<\/a>\u3068\u306e\u3053\u3068\u3060\u3063\u305f\u306e\u3067\u3001\u300cPHP\u3067caching_sha2_password\u306f\u5225\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3060\u3057mysqlnd\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u632f\u308b\u821e\u3044\u304clibmysqlclient\u3068\u7570\u306a\u308a\u305d\u3046\u3060\u3057\u3001PHP\u306ecaching_sha2_password\u5bfe\u5fdc\u306b\u3064\u3044\u3066\u306f\u30c7\u30d0\u30c3\u30ac\u3067\u52d5\u304b\u3057\u3066\u307f\u306a\u3044\u3068\u4f55\u3068\u3082\u308f\u304b\u3089\u3093\u306a\u3041\u300d\u3068\u306a\u3063\u305f\u306e\u3067\u3001gdb\u3092\u6301\u3061\u51fa\u3059\u904b\u3073\u3068\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>yoku0825\u3055\u3093\u306b\u306f\u3001\u3053\u306e\u5834\u3092\u501f\u308a\u3066\u5fa1\u793c\u7533\u3057\u4e0a\u3052\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u308f\u3002\u305b\u3058\u307e\u3067\u3059\u3002PHP\u306b\u306f\u758e\u3044\u3093\u3067\u3059\u304c\u3001\u4eca\u56de\u306f\u73cd\u3057\u304fPHP\u306e\u8a71\u3092\u3057\u307e\u3059\u3002 \u306f\u3058\u3081\u306b 2023-07-18 \u306b MySQL 8.1.0 \u304c\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u307e\u3057\u305f\u3002\u3044\u304f\u3064\u304b\u6c17\u306b\u306a\u308b\u5909\u66f4\u304c\u5165\u3063\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u4eca\u56de\u306f The [&hellip;]<\/p>\n","protected":false},"author":137,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[17,8],"class_list":["post-22581","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-info","tag-mysql","tag-php"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/22581","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/users\/137"}],"replies":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/comments?post=22581"}],"version-history":[{"count":3,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/22581\/revisions"}],"predecessor-version":[{"id":22583,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/22581\/revisions\/22583"}],"wp:attachment":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/media?parent=22581"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/categories?post=22581"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/tags?post=22581"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}