Description
Description
The mysql command line client and related tools verify SSL certificates, but by default do not verify that the server name used to connect matches the Subject CN, or one of the SAN extension entries, of the server certificate.
This additional verification needs to be requested using the --ssl-verify-server-cert
option (which was not the best name for this, -ssl-verify-server-cert-hostname
would have been a better choice, bu that is a different story); or when using encrypted replication: the MASTER_SSL_VERIFY_SERVER_CERT=1
option to CHANGE MASTER
.
With mysqlnd
though both verification aspects are tightly coupled, and can only be both on, or both off, controlled by the single MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT
flag.
See also: ext/mysqlnd/mysqlnd_vio.c
:
555 ZVAL_BOOL(&verify_peer_zval, verify);
556 php_stream_context_set_option(context, "ssl", "verify_peer", &verify_peer_zval);
557 php_stream_context_set_option(context, "ssl", "verify_peer_name", &verify_peer_zval);
https://github.com/php/php-src/blob/master/ext/mysqlnd/mysqlnd_vio.c#L555
There needs to be an extra option like MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_HOSTNAME
to control hostname verification independent of general certificate verification.
PHP Version
PHP 8.1.2
Operating System
Ubuntu 22.04