We have a server with mysql on port 3306. We have sertifications and key and we try to connect to this server. But we see such problem:
Peer certificate CN='SomeName' did not match expected CN='someIP'
I've read a lot of articles and can't find answer for PDO PHP. The most interesting is that the SQLYog could connect with all settings.
I've read that I verify_peer_names can be disabled (I hope I understand what is peer_names...), but only if we use openssl_{functions} or mysqli, not PDO. Both options are not appropriate for me. I need PDO.
What I tried to do:
- switch between versions of php. It helped me, but I need 5.6 or higher. For php 7.0 the same error.
- find another versions of openssl and pdo; fast I understood that its a bad idea :)
- find some settings in php.ini, but no settings for my problem, only for creating ssl.
My code for connection:
$dbInfo = array
(
'dsn' => 'mysql:host=123.45.67.890;dbname=someDB;port=3306',
'user' => 'user',
'pass' => 'userpassword'
);
$con = new PDO
(
$dbInfo['dsn'], $dbInfo['user'], $dbInfo['pass'],
array(
PDO::MYSQL_ATTR_SSL_CIPHER => 'AES256-SHA',
PDO::MYSQL_ATTR_SSL_CA => 'SSLCert/ca-cert.pem',
PDO::MYSQL_ATTR_SSL_KEY => 'SSLCert/client-key.pem',
PDO::MYSQL_ATTR_SSL_CERT => 'SSLCert/client-cert.pem',
)
);
echo 'Connection OK!';