cakephp/cakephp — pull request #1415 by mikescar (2013-07-11 20:37:53+00:00)
Title: add SSL support to MySQL PDO connections

I had a project which required SSL communication between the web box and MySQL server, so I added checks of the config in app/Config/database.php to check for the presence of cert options. If accepted I can write documentation.

I don't have a way to test support for other databases, but this code works for projects that do and do not require SSL, and the 'ssl_ca' is optional but not recommended, to avoid MITM.

Config options like this will work:

public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'remote_server',
'login' => 'mysql_user',
'password' => 'my_secure_password',
'database' => 'my_db_name',
'prefix' => '',
'encoding' => 'utf8',
'ssl_key' => '/etc/pki/tls/certs/mysql-client-key.pem',
'ssl_cert' => '/etc/pki/tls/certs/mysql-client-cert.pem',
'ssl_ca' => '/etc/pki/tls/certs/mysql-ca-cert.pem'
);