Skip to content

Commit

Permalink
Merge pull request #43 from Icinga/fix/mysql-empy-string-ssl-attributes
Browse files Browse the repository at this point in the history
Fix handling of empty strings for MySQL SSL attributes and that values considered empty() also disable server cert verification
  • Loading branch information
nilmerg authored Jul 20, 2021
2 parents c832144 + d0da92b commit 4bae3fb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Adapter/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,30 @@ public function getOptions(Config $config)
{
$options = parent::getOptions($config);

if (isset($config->use_ssl) && $config->use_ssl === '1') {
if (isset($config->ssl_key)) {
if (! empty($config->use_ssl)) {
if (! empty($config->ssl_key)) {
$options[PDO::MYSQL_ATTR_SSL_KEY] = $config->ssl_key;
}

if (isset($config->ssl_cert)) {
if (! empty($config->ssl_cert)) {
$options[PDO::MYSQL_ATTR_SSL_CERT] = $config->ssl_cert;
}

if (isset($config->ssl_ca)) {
if (! empty($config->ssl_ca)) {
$options[PDO::MYSQL_ATTR_SSL_CA] = $config->ssl_ca;
}

if (isset($config->ssl_capath)) {
if (! empty($config->ssl_capath)) {
$options[PDO::MYSQL_ATTR_SSL_CAPATH] = $config->ssl_capath;
}

if (isset($config->ssl_cipher)) {
if (! empty($config->ssl_cipher)) {
$options[PDO::MYSQL_ATTR_SSL_CIPHER] = $config->ssl_cipher;
}

if (
defined('PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT')
&& isset($config->ssl_do_not_verify_server_cert)
&& ! empty($config->ssl_do_not_verify_server_cert)
) {
$options[PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT] = false;
}
Expand Down

0 comments on commit 4bae3fb

Please sign in to comment.