From 6a5b0abbb4681e530eea4bd7ead4794e6c14ca57 Mon Sep 17 00:00:00 2001 From: "grass@dionera.com" Date: Fri, 5 Apr 2019 10:34:21 +0200 Subject: [PATCH] Check if PDO SSL Attributes are set within config, and only set them in PDO Options. otherwise Mysql PDO throws errors if attribute is set and empty --- adminer/drivers/mysql.inc.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index 4dc0cc19..4d704fc5 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -238,11 +238,15 @@ if (!defined("DRIVER")) { $options = array(PDO::MYSQL_ATTR_LOCAL_INFILE => false); $ssl = $adminer->connectSsl(); if ($ssl) { - $options += array( - PDO::MYSQL_ATTR_SSL_KEY => $ssl['key'], - PDO::MYSQL_ATTR_SSL_CERT => $ssl['cert'], - PDO::MYSQL_ATTR_SSL_CA => $ssl['ca'], - ); + if (!empty($ssl['key'])) { + $options[PDO::MYSQL_ATTR_SSL_KEY] = $ssl['key']; + } + if (!empty($ssl['cert'])) { + $options[PDO::MYSQL_ATTR_SSL_CERT] = $ssl['cert']; + } + if (!empty($ssl['ca'])) { + $options[PDO::MYSQL_ATTR_SSL_CA] = $ssl['ca']; + } } $this->dsn( "mysql:charset=utf8;host=" . str_replace(":", ";unix_socket=", preg_replace('~:(\d)~', ';port=\1', $server)),