diff --git a/Tests/Mock/Driver.php b/Tests/Mock/Driver.php index b5aec54c1..2c146103b 100644 --- a/Tests/Mock/Driver.php +++ b/Tests/Mock/Driver.php @@ -49,6 +49,7 @@ public static function create(TestCase $test, $nullDate = '0000-00-00 00:00:00', 'getCollation', 'getConnectionCollation', 'getConnectionEncryption', + 'isConnectionEncryptionSupported', 'getConnectors', 'getDateFormat', 'getInstance', diff --git a/Tests/Stubs/nosqldriver.php b/Tests/Stubs/nosqldriver.php index e8384c87c..5ced55b02 100644 --- a/Tests/Stubs/nosqldriver.php +++ b/Tests/Stubs/nosqldriver.php @@ -227,6 +227,18 @@ public function getConnectionEncryption(): string return ''; } + /** + * Method to test if the database TLS connections encryption are supported. + * + * @return boolean Whether the databse supports TLS connections encryption. + * + * @since __DEPLOY_VERSION__ + */ + public function isConnectionEncryptionSupported(): bool + { + return false; + } + /** * Get the number of returned rows for the previous executed SQL statement. * diff --git a/src/DatabaseInterface.php b/src/DatabaseInterface.php index da850ce56..6ff90b6f6 100644 --- a/src/DatabaseInterface.php +++ b/src/DatabaseInterface.php @@ -149,6 +149,15 @@ public function getConnectionCollation(); */ public function getConnectionEncryption(): string; + /** + * Method to test if the database TLS connections encryption are supported. + * + * @return boolean Whether the databse supports TLS connections encryption. + * + * @since __DEPLOY_VERSION__ + */ + public function isConnectionEncryptionSupported(): bool; + /** * Get the total number of SQL statements executed by the database driver. * diff --git a/src/Mysql/MysqlDriver.php b/src/Mysql/MysqlDriver.php index b8223f72a..84ef4be64 100644 --- a/src/Mysql/MysqlDriver.php +++ b/src/Mysql/MysqlDriver.php @@ -361,6 +361,22 @@ public function getConnectionEncryption(): string return ''; } + /** + * Method to test if the database TLS connections encryption are supported. + * + * @return boolean Whether the databse supports TLS connections encryption. + * + * @since __DEPLOY_VERSION__ + */ + public function isConnectionEncryptionSupported(): bool + { + $this->connect(); + + $variables = $this->setQuery('SHOW SESSION VARIABLES WHERE `Variable_name` IN (\'have_ssl\')')->loadObjectList('Variable_name'); + + return !empty($variables['have_ssl']->Value) && $variables['have_ssl']->Value === 'YES'; + } + /** * Return the query string to create new Database. * diff --git a/src/Mysqli/MysqliDriver.php b/src/Mysqli/MysqliDriver.php index 1267d12df..7d2cca7dd 100644 --- a/src/Mysqli/MysqliDriver.php +++ b/src/Mysqli/MysqliDriver.php @@ -484,6 +484,22 @@ public function getConnectionEncryption(): string return ''; } + /** + * Method to test if the database TLS connections encryption are supported. + * + * @return boolean Whether the databse supports TLS connections encryption. + * + * @since __DEPLOY_VERSION__ + */ + public function isConnectionEncryptionSupported(): bool + { + $this->connect(); + + $variables = $this->setQuery('SHOW SESSION VARIABLES WHERE `Variable_name` IN (\'have_ssl\')')->loadObjectList('Variable_name'); + + return !empty($variables['have_ssl']->Value) && $variables['have_ssl']->Value === 'YES'; + } + /** * Return the query string to create new Database. * diff --git a/src/Pgsql/PgsqlDriver.php b/src/Pgsql/PgsqlDriver.php index ca25dcf98..8bb5f82e7 100644 --- a/src/Pgsql/PgsqlDriver.php +++ b/src/Pgsql/PgsqlDriver.php @@ -158,6 +158,20 @@ public function getConnectionEncryption(): string return ''; } + /** + * Method to test if the database TLS connections encryption are supported. + * + * @return boolean Whether the databse supports TLS connections encryption. + * + * @since __DEPLOY_VERSION__ + */ + public function isConnectionEncryptionSupported(): bool + { + $variables = $this->setQuery('SHOW "ssl"')->loadAssoc(); + + return !empty($variables['ssl']) && $variables['ssl'] === 'on'; + } + /** * Shows the table CREATE statement that creates the given tables. * diff --git a/src/Sqlite/SqliteDriver.php b/src/Sqlite/SqliteDriver.php index f2d89681d..81262c04c 100644 --- a/src/Sqlite/SqliteDriver.php +++ b/src/Sqlite/SqliteDriver.php @@ -182,6 +182,19 @@ public function getConnectionEncryption(): string return ''; } + /** + * Method to test if the database TLS connections encryption are supported. + * + * @return boolean Whether the databse supports TLS connections encryption. + * + * @since __DEPLOY_VERSION__ + */ + public function isConnectionEncryptionSupported(): bool + { + // TODO: Not fake this + return false; + } + /** * Shows the table CREATE statement that creates the given tables. * diff --git a/src/Sqlsrv/SqlsrvDriver.php b/src/Sqlsrv/SqlsrvDriver.php index ea5f2b92c..9476f2f04 100644 --- a/src/Sqlsrv/SqlsrvDriver.php +++ b/src/Sqlsrv/SqlsrvDriver.php @@ -368,6 +368,19 @@ public function getConnectionEncryption(): string return ''; } + /** + * Method to test if the database TLS connections encryption are supported. + * + * @return boolean Whether the databse supports TLS connections encryption. + * + * @since __DEPLOY_VERSION__ + */ + public function isConnectionEncryptionSupported(): bool + { + // TODO: Not fake this + return false; + } + /** * Retrieves field information about the given tables. *