CESNET / pakiti-server

Pakiti provides a monitoring mechanism to check the patching status of Linux systems.
BSD 2-Clause "Simplified" License
49 stars 35 forks source link

Add MySQL SSL support #198

Open matejzero opened 5 months ago

matejzero commented 5 months ago

We are using Pakiti with MySQL that only allows SSL connections. As far as I looked, that is not natively supported, but I managed to make it work by changing the connect function in https://github.com/CESNET/pakiti-server/blob/master/src/managers/DbManager.php#L130.

Changing $this->_dbLink = new mysqli(Config::$DB_HOST, Config::$DB_USER, Config::$DB_PASSWORD); to

$this->_dbLink = mysqli_init();
$this->_dbLink->real_connect(Config::$DB_HOST, Config::$DB_USER, Config::$DB_PASSWORD, NULL, NULL, NULL, MYSQLI_CLIENT_SSL );

worked for me.

But this will work if you don't have self-signed certs and must use SSL connection.

My knowledge of php is not good enough to produce a nice PR to add support for SSL. But if there is anyone that wants to implement this, a few config options would probably be needed: