Skip to content

Commit

Permalink
Add SSL support back to MySQL driver.
Browse files Browse the repository at this point in the history
This was lost in the 2.x -> 3.x migration. Re-add the documented
options.
  • Loading branch information
markstory committed Nov 13, 2013
1 parent 0e69337 commit ade1d08
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Cake/Database/Driver/Mysql.php
Expand Up @@ -59,13 +59,22 @@ public function connect() {
}

$config['init'][] = sprintf("SET time_zone = '%s'", $config['timezone']);

$config['flags'] += [
PDO::ATTR_PERSISTENT => $config['persistent'],
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::MYSQL_ATTR_INIT_COMMAND => implode(';', (array)$config['init'])
];

if (!empty($config['ssl_key']) && !empty($config['ssl_cert'])) {
$config['flags'][PDO::MYSQL_ATTR_SSL_KEY] = $config['ssl_key'];
$config['flags'][PDO::MYSQL_ATTR_SSL_CERT] = $config['ssl_cert'];
}
if (!empty($config['ssl_ca'])) {
$config['flags'][PDO::MYSQL_ATTR_SSL_CA] = $config['ssl_ca'];
}

if (empty($config['dsn'])) {
if (empty($config['unix_socket'])) {
$config['dsn'] = "mysql:host={$config['host']};port={$config['port']};dbname={$config['database']};charset={$config['encoding']}";
Expand Down

0 comments on commit ade1d08

Please sign in to comment.