diff --git a/app/Config/Database.php b/app/Config/Database.php index 5790932e..2d388192 100755 --- a/app/Config/Database.php +++ b/app/Config/Database.php @@ -20,7 +20,8 @@ class Database extends Config * use if no other is specified. */ public string $defaultGroup = 'default'; - + public string $enableSSL; + /** * The default database connection. */ @@ -37,7 +38,7 @@ class Database extends Config 'charset' => 'utf8', 'DBCollat' => 'utf8_general_ci', 'swapPre' => '', - 'encrypt' => ['ssl_verify' => true,'ssl_ca' => ROOTPATH .'ca.pem'], + 'encrypt' =>false, 'compress' => false, 'strictOn' => false, 'failover' => [], @@ -122,6 +123,18 @@ class Database extends Config if (ENVIRONMENT === 'testing') { $this->defaultGroup = 'tests'; } + + $this->enableSSL = env('DB_SSL_ENABLE'); + + if ($this->enableSSL === true || $this->enableSSL === 'true' || $this->enableSSL === 1 || $this->enableSSL === '1') { + + + // Enable SSL authentication + $this->default['encrypt'] = [ + 'ssl_ca' => ROOTPATH . 'ca.pem', + 'ssl_verify' => true, + ]; + } } }