Page 1 of 1

How to connect HESK to Azure MySQL Database over SSL

Posted: Thu Feb 20, 2020 12:13 am
by cjanuzi
Script URL:
Version of script:
Hosting company:
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:
MYSQLI_CLIENT_SSL, mysqli_connect, SSL, Azure
Write your message below:

Hi everyone, I found this forum but unfortunately I couldn't find the solution to my problem. I would like to share with you if anyone knows how to solve, please share it!

My HESK is published on Azure.
My environment is a Linux WebApp with PHP7.2.
And my database is a MySQL Database from Azure.
To meet some security requirements, we had to enable SSL-ENFORCED in the MySQL Azure Database and include the ips of the WebApp in the db access permissions, as well as determine the best practices. My problem is in the connection string between HESK and the database, when accessing the page it returns the following message: (9002) SSL connection is required. Please specify SSL options and retry.
I don't know how to proceed with this configuration in the db connection string.

File: database_mysqli.inc.php
Code:
function hesk_dbConnect()
{
global $hesk_settings;
global $hesk_db_link;
global $hesklang;

// Do we have an existing active link?
if ($hesk_db_link)
{
return $hesk_db_link;
}

// Is mysqli supported?
if ( ! function_exists('mysqli_connect') )
{
die($hesklang['emp']);
}

// Do we need a special port? Check and connect to the database
if ( strpos($hesk_settings['db_host'], ':') )
{
list($hesk_settings['db_host_no_port'], $hesk_settings['db_port']) = explode(':', $hesk_settings['db_host']);
$hesk_db_link = @mysqli_connect($hesk_settings['db_host_no_port'], $hesk_settings['db_user'], $hesk_settings['db_pass'], $hesk_settings['db_name'], intval($hesk_settings['db_port']) );
}
else
{
$hesk_db_link = @mysqli_connect($hesk_settings['db_host'], $hesk_settings['db_user'], $hesk_settings['db_pass'], $hesk_settings['db_name']);
}

// Errors?
if ( ! $hesk_db_link)
{
if ($hesk_settings['debug_mode'])
{
hesk_error("$hesklang[cant_connect_db]</p><p>$hesklang[mysql_said]:<br />(".mysqli_connect_errno().") ".mysqli_connect_error()."</p>");
}
else
{
hesk_error("$hesklang[cant_connect_db]</p><p>$hesklang[contact_webmsater] <a href=\"mailto:$hesk_settings[webmaster_mail]\">$hesk_settings[webmaster_mail]</a></p>");
}
}

// Check MySQL/PHP version and set encoding to utf8
hesk_dbSetNames();

// Set the correct timezone
hesk_dbSetTimezone();

return $hesk_db_link;

} // END hesk_dbConnect()
I tried several searches on Google, but they always say to set up certificates for the database, which is not my case, I just need to inform the system that I should force the use of SSL.
Does anyone have an example or solution?
Thanks!

Re: How to connect HESK to Azure MySQL Database over SSL

Posted: Thu Feb 20, 2020 7:08 am
by Klemen
Are you able to create a test database at Azure and send me the login information (via private message) so I can test this?

Re: How to connect HESK to Azure MySQL Database over SSL

Posted: Thu Feb 20, 2020 8:07 pm
by cjanuzi
Hi Klemen, thanks for your help.
I sent you an email containing the access and what I need to release the firewall on Azure MySQL DB, ok.

Re: How to connect HESK to Azure MySQL Database over SSL

Posted: Sun Jun 12, 2022 9:46 pm
by sabya1986
Hi, can you please post the solution to this. I am facing the similar challenge where Hesk is not able to connect to Azure MySQL DB during installation.

Re: How to connect HESK to Azure MySQL Database over SSL

Posted: Mon Jun 13, 2022 11:18 am
by Klemen
What is the exact error message you get?

Re: How to connect HESK to Azure MySQL Database over SSL

Posted: Thu Oct 12, 2023 12:18 pm
by Klemen
Thanks for sharing what worked for you.