formtools / core

The Form Tools Core.
https://formtools.org
205 stars 78 forks source link

Connecting to Azure DB SSL required #842

Closed Somotano closed 2 years ago

Somotano commented 2 years ago

Hi all, I am trying to connect to a DB on an Azure server which requires SSL settings, unfortunately when trying to install I get the error message

**Sorry, we were unable to connect to the database using the information you supplied. The error message the database returned is: SQLSTATE[HY000] [9002] SSL connection is required. Please specify SSL options and retry.

Please double-check your database settings and click the Continue button again**

Any help in achieving this would be greatly appreciated, Cheers

image

Somotano commented 2 years ago

Hi all,

Just to let any who is having the same issue, or will be using an Azure DB which requires SSL settings, after playing around within the formtools classes I found a couple of places where I could actually add the PDO options.

Added SSL options

PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', PDO::MYSQL_ATTR_SSL_CA => false, PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false

installation.class.php->checkConnection()

try { $dsn = sprintf("mysql:host=%s;port=%s;dbname=%s;charset=utf8", $hostname, $port, $db_name); new PDO($dsn, $username, $password, array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', PDO::MYSQL_ATTR_SSL_CA => false, PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false) ); } catch (Exception $e) { return array(false, $e->getMessage()); }

database.class.php->__construct

$options = array( PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_EMULATE_PREPARES => false, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', PDO::MYSQL_ATTR_SSL_CA => false, PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false );