From c2b20fc0b4c6c1271fff9a85cb977d23de0a3421 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 31 Jul 2012 13:21:03 +0200 Subject: Added support for SSL connection parameters in mysql driver (#1486594) --- program/include/rcube_db_mysql.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'program/include/rcube_db_mysql.php') diff --git a/program/include/rcube_db_mysql.php b/program/include/rcube_db_mysql.php index 38b15fa42..3606ec102 100644 --- a/program/include/rcube_db_mysql.php +++ b/program/include/rcube_db_mysql.php @@ -59,6 +59,10 @@ class rcube_db_mysql extends rcube_db /** * Returns PDO DSN string from DSN array + * + * @param array $dsn DSN parameters + * + * @return string Connection string */ protected function dsn_string($dsn) { @@ -90,6 +94,40 @@ class rcube_db_mysql extends rcube_db return $result; } + /** + * Returns driver-specific connection options + * + * @param array $dsn DSN parameters + * + * @return array Connection options + */ + protected function dsn_options($dsn) + { + $result = array(); + + if (!empty($dsn['key'])) { + $result[PDO::MYSQL_ATTR_KEY] = $dsn['key']; + } + + if (!empty($dsn['cipher'])) { + $result[PDO::MYSQL_ATTR_CIPHER] = $dsn['cipher']; + } + + if (!empty($dsn['cert'])) { + $result[PDO::MYSQL_ATTR_SSL_CERT] = $dsn['cert']; + } + + if (!empty($dsn['capath'])) { + $result[PDO::MYSQL_ATTR_SSL_CAPATH] = $dsn['capath']; + } + + if (!empty($dsn['ca'])) { + $result[PDO::MYSQL_ATTR_SSL_CA] = $dsn['ca']; + } + + return $result; + } + /** * Get database runtime variables * -- cgit v1.2.3