I'm trying to set up an SSL connection between two servers (Laravel and MySQL 8). The options in database.php for this connection are:
'db_connection' => [
'driver' => 'mysql',
'host' => '192.168.0.1',
'port' => '3306',
'database' => 'my_db',
'username' => 'my_user',
'password' => 'my_password',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false,
PDO::MYSQL_ATTR_SSL_CA => '/path/ca.pem',
PDO::MYSQL_ATTR_SSL_KEY => '/path/client-key.pem',
PDO::MYSQL_ATTR_SSL_CERT => '/path/client-cert.pem',
]) : [],
],
Now even though I set MYSQL_ATTR_SSL_VERIFY_SERVER_CERT
to false
but I still get this error:
PDO::__construct(): Peer certificate CN=`MySQL_Server_8.0.xx_Auto_Generated_Server_Certificate' did not match expected CN=`192.168.0.1'
I also tried to remove MYSQL_ATTR_SSL_CA
But then I get this error:
SQLSTATE[HY000] [3159] Connections using insecure transport are prohibited while --require_secure_transport=ON.
I even tried to set MYSQL_ATTR_SSL_CA
to '/dev/null'
but I get this error:
failed loading cafile stream: `/dev/null'
It seems MYSQL_ATTR_SSL_VERIFY_SERVER_CERT
is not working at all. How can I resolve my issue and disable SSL certification verification in Laravel?
Thanks.