mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-06-21 12:09:31 -04:00
Add a ZM_DB_SSL_VERIFY_SERVER_CERT setting so a database connection that uses ZM_DB_SSL_CA_CERT can talk to a server with a self-signed or otherwise non-matching certificate. When enabled, verification is by identity (the cert must chain to the CA and its CN/SAN must match ZM_DB_HOST), consistent across the C++ daemons, the PHP web interface, the CakePHP API and the Perl scripts. This re-does the reverted #3817. That PR broke the build because it called mysql_options(MYSQL_OPT_SSL_VERIFY_SERVER_CERT, ...), and that enum was removed from the MySQL 8.0 C client in favour of MYSQL_OPT_SSL_MODE; it also passed a c_str() where a my_bool* was expected, and referenced the PHP constant unconditionally (fatal on PHP 8 for an upgraded install whose zm.conf predates the option). The option that controls server-cert verification differs by client library and the symbols are enum values, not macros, so CMake feature-detects them by compiling: - HAVE_MYSQL_OPT_SSL_MODE (MySQL 5.7.11+/8.0, MariaDB Connector/C 3.1+) - HAVE_MYSQL_OPT_SSL_VERIFY_SERVER_CERT (older MariaDB/MySQL) zm_db.cpp uses SSL_MODE_VERIFY_IDENTITY / SSL_MODE_REQUIRED when the former is available, else falls back to the latter with a proper my_bool. Value handling is three-way in every layer: a truthy value verifies, a false-y value (0/false/no/off) skips verification, and an empty/unset value leaves the client default in place so existing installs are unchanged on upgrade. PHP, the API datasource (via PDO flags) and the Perl DSN are all guarded with defined() checks. Fresh installs default to 1. Documents the full ZM_DB_* connection and SSL settings, including the hostname verification gotcha when connecting by IP, in docs/userguide/configfiles.rst. refs #3816