Skip to content

Commit

Permalink
Merge pull request #2816 from gauauu/fix/#2815-mysqli-ssl-key-should-…
Browse files Browse the repository at this point in the history
…not-be-reqd

#2815 don't require `ssl_key` and `ssl_cert` to use `ssl_ca`

Fixes: #2815
  • Loading branch information
lcobucci authored Nov 19, 2017
2 parents ea968df + c9f50b9 commit edfbda1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 38 deletions.
9 changes: 2 additions & 7 deletions lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,9 @@ private function setSecureConnection(array $params)
return;
}

if (! isset($params['ssl_key']) || ! isset($params['ssl_cert'])) {
$msg = '"ssl_key" and "ssl_cert" parameters are mandatory when using secure connection parameters.';
throw new MysqliException($msg);
}

$this->_conn->ssl_set(
$params['ssl_key'],
$params['ssl_cert'],
$params['ssl_key'] ?? null,
$params['ssl_cert'] ?? null,
$params['ssl_ca'] ?? null,
$params['ssl_capath'] ?? null,
$params['ssl_cipher'] ?? null
Expand Down
29 changes: 0 additions & 29 deletions tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,34 +50,5 @@ public function testRestoresErrorHandlerOnException()
restore_error_handler();
}

/**
* @dataProvider secureMissingParamsProvider
*/
public function testThrowsExceptionWhenMissingMandatorySecureParams(array $secureParams)
{
$this->expectException(MysqliException::class);
$msg = '"ssl_key" and "ssl_cert" parameters are mandatory when using secure connection parameters.';
$this->expectExceptionMessage($msg);

new MysqliConnection($secureParams, 'xxx', 'xxx');
}

public function secureMissingParamsProvider()
{
return [
[
['ssl_cert' => 'cert.pem']
],
[
['ssl_key' => 'key.pem']
],
[
['ssl_key' => 'key.pem', 'ssl_ca' => 'ca.pem', 'ssl_capath' => 'xxx', 'ssl_cipher' => 'xxx']
],
[
['ssl_ca' => 'ca.pem', 'ssl_capath' => 'xxx', 'ssl_cipher' => 'xxx']
]
];
}
}

4 changes: 2 additions & 2 deletions tests/travis/install-mysql-5.7.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ sudo apt-get remove "^mysql.*"
sudo apt-get autoremove
sudo apt-get autoclean
echo mysql-apt-config mysql-apt-config/select-server select mysql-5.7 | sudo debconf-set-selections
wget http://dev.mysql.com/get/mysql-apt-config_0.8.6-1_all.deb
sudo DEBIAN_FRONTEND=noninteractive dpkg -i mysql-apt-config_0.8.6-1_all.deb
wget http://dev.mysql.com/get/mysql-apt-config_0.8.9-1_all.deb
sudo DEBIAN_FRONTEND=noninteractive dpkg -i mysql-apt-config_0.8.9-1_all.deb
sudo rm -rf /var/lib/apt/lists/*
sudo apt-get clean
sudo apt-get update -q
Expand Down

0 comments on commit edfbda1

Please sign in to comment.