Permalink
Browse files

Added support for SSL connection parameters in mysql driver (#1486594)

  • Loading branch information...
alecpl committed Jul 31, 2012
1 parent 146106a commit c2b20fc0b4c6c1271fff9a85cb977d23de0a3421
Showing with 38 additions and 0 deletions.
  1. +38 −0 program/include/rcube_db_mysql.php
@@ -59,6 +59,10 @@ public function concat(/* col1, col2, ... */)
/**
* 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 @@ protected function dsn_string($dsn)
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
*

0 comments on commit c2b20fc

Please sign in to comment.