0

I can connect the database with Maria client with --ssl options on application server:

mariadb -h [Address] -P [Port] -u [DB admin user] -p --ssl

But tried to connect the same database on same server with PHP PDO, we got the error message with:

SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client[client_ed25519]

I have added below options to PDO connection for simulate the --ssl options

   PDO::MYSQL_ATTR_SSL_CA => true,
   PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false,

Here is my testing code piece:

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$options = [
    PDO::MYSQL_ATTR_SSL_CA => true,
    PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false,
];

try {
  $conn = new PDO("mysql:host=$servername;dbname=myDB", $username, $password, $options);
  // set the PDO error mode to exception
  $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  echo "Connected successfully";
} catch(PDOException $e) {
  echo "Connection failed: " . $e->getMessage();
}
?>

Database version: MariaDB 10.5

Min
  • 1
  • 1
  • One more response message: The server requested authentication method unknown to the client [client_ed25519] – Min Nov 27 '21 at 00:17
  • Does this question help you: https://stackoverflow.com/questions/9738712/connect-to-remote-mysql-server-with-ssl-from-php – esQmo_ Nov 27 '21 at 00:22
  • The following is what we're using in our application ```$conn->exec("SET GLOBAL ssl_ca = '/etc/mysql/cacert.pem'");``` ```$conn->exec("SET GLOBAL ssl_verify_server_cert = 1");``` – esQmo_ Nov 27 '21 at 00:25
  • Server: PHP8.0 MariaDB 10.5 – Min Nov 27 '21 at 00:33
  • Thanks es!mo_, but it is require the client cert and key provided, but may we same as client to trust server cert instead. – Min Nov 27 '21 at 00:38
  • I found the problem is unable to process the authentication method by ed25519 which is database server is using and we unable to change it. May I know if PHP-MYSQLND is supported this authentication method or not. – Min Nov 29 '21 at 03:07

0 Answers0