Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Olega's avatar
Level 1

Enable mysql ssl

Hi, i need to enable SSL and Remote Connections for MySQL. I am doing it like this:


'options' => extension_loaded('pdo_mysql') ? array_filter([
  PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_CA'),
  PDO::MYSQL_ATTR_SSL_KEY => env('MYSQL_KEY'),
  PDO::MYSQL_ATTR_SSL_CERT => env('MYSQL_CERT'),
  PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false,
]) : [],

But i am getting:

 PDOException::("PDO::__construct(): Peer certificate CN=`MySQL_Server_8.0.18_Auto_Generated_Server_Certificate' did not match expected CN=`10.100.2.3`

10.100.2.3 - mysql server

How can i solve it?

P.S.

it works

mysql -u admin -p -h 10.100.2.3 --ssl-ca=ca.pem --ssl-cert=client-cert.pem --ssl-key=client-key.pem

0 likes
0 replies

Please or to participate in this conversation.