Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Unattended Install: unable to connect to MySQL with TLS #694

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions setup/unattended-install/unattended-install.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ function PrintUsageAndExit()
$sDBPwd = $aDBXmlSettings['pwd'];
$sDBName = $aDBXmlSettings['name'];
$sDBPrefix = $aDBXmlSettings['prefix'];
$bDBTlsEnabled = $aDBXmlSettings['db_tls_enabled'];
$sDBTlsCa = $aDBXmlSettings['db_tls_ca'];

if ($sMode == 'install')
{
Expand Down Expand Up @@ -217,7 +219,16 @@ function PrintUsageAndExit()
die("Cleanup not implemented for a partial database (prefix= '$sDBPrefix')\nExiting.");
}

$oMysqli = new mysqli($sDBServer, $sDBUser, $sDBPwd);
$oMysqli = new mysqli();
$iMySqlFlag = 0;
if ($bDBTlsEnabled)
{
$iMySqlFlag = (empty($sDBTlsCa))
? MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT
: MYSQLI_CLIENT_SSL;
$oMysqli->ssl_set($bDBTlsEnabled, null, $sDBTlsCa, null, null);
}
$oMysqli->real_connect($sDBServer, $sDBUser, $sDBPwd, null, null, null, $iMySqlFlag);
if ($oMysqli->connect_errno)
tomrss marked this conversation as resolved.
Show resolved Hide resolved
{
die("Cannot connect to the MySQL server (".$oMysqli->connect_errno . ") ".$oMysqli->connect_error."\nExiting");
Expand Down Expand Up @@ -310,7 +321,16 @@ function PrintUsageAndExit()
}
else
{
$oMysqli = new mysqli($sDBServer, $sDBUser, $sDBPwd);
$oMysqli = new mysqli();
$iMySqlFlag = 0;
if ($bDBTlsEnabled)
{
$iMySqlFlag = (empty($sDBTlsCa))
? MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT
: MYSQLI_CLIENT_SSL;
$oMysqli->ssl_set($bDBTlsEnabled, null, $sDBTlsCa, null, null);
}
$oMysqli->real_connect($sDBServer, $sDBUser, $sDBPwd, null, null, null, $iMySqlFlag);
if (!$oMysqli->connect_errno)
tomrss marked this conversation as resolved.
Show resolved Hide resolved
{
if ($oMysqli->select_db($sDBName))
Expand Down