SSL self-signed certifications to connect with Mysql with PHP

╄→尐↘猪︶ㄣ 提交于 2019-12-04 06:36:26

It looks like the 2 relevant bugs in PHP are still not entirely resolved: #68344 and #71003.

Unfortunately, this is not possible yet. PHP does a lookup and the result will not match the self-signed certificate. One will contain the name and the other will contain the IP.

There is no way [currently] to have PHP ignore this, therefor connecting in this instance, via SSL, is not possible.

you need to Replace

$query = mysqli_real_connect ($db, $host, $user, $pass, $dbname, 3306, NULL, MYSQLI_CLIENT_SSL);

With

$query = mysqli_real_connect ($db, $host, $user, $pass, $dbname, 3306, NULL, MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT);

it is Like MYSQLI_CLIENT_SSL, but disables validation of the provided SSL certificate. This is only for installations using MySQL Native Driver and MySQL 5.6 or later.

Hope it will help.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!