From 7edccbe38b08bd56240b8b8769902ad31563ba7f Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Mon, 8 May 2023 17:39:31 -0700 Subject: [PATCH] Newer DBD::mysql versions need to set mysql_ssl_optional to not fail if mandatory SSL isn't supported https://forum.virtualmin.com/t/remote-mysql-server-ssl-connection-issue/120683 --- mysql/mysql-lib.pl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mysql/mysql-lib.pl b/mysql/mysql-lib.pl index d8b170372..944f1f0c5 100755 --- a/mysql/mysql-lib.pl +++ b/mysql/mysql-lib.pl @@ -327,7 +327,12 @@ if ($driver_handle && !$config{'nodbi'}) { $cstr .= ";mysql_socket=$config{'sock'}" if ($config{'sock'}); $cstr .= ";mysql_read_default_file=$config{'my_cnf'}" if (-r $config{'my_cnf'}); - $cstr .= ";mysql_ssl=1" if ($config{'ssl'}); + if ($config{'ssl'}) { + $cstr .= ";mysql_ssl=1"; + if ($DBD::mysql::VERSION >= 4.043) { + $cstr .= ";mysql_ssl_optional=1"; + } + } local $dbh = $driver_handle->connect($cstr, $mysql_login, $mysql_pass, { }); $dbh || &error("DBI connect failed : ",$driver_handle->errstr);