Skip to content

ext-mysqlnd: can't set SSL server hostname verification independent of general certificate validation #8769

Open
@hartmut-mariadb

Description

@hartmut-mariadb

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions