Welcome Guest, Not a member yet? Register   Sign In
Can't connect to MySQL (Azure) using SSL encrypt connection
#1

Well, i do a connection successfully, in the same server, when using mysqli_real_connect as we can see below:

PHP Code:
$host 'myhost.mysql.database.azure.com';
$username 'user';
$password 'pass';
$db_name 'foo';
$conn mysqli_init();
if(!
$conn) {
 die(
'No init');
}

mysqli_real_connect($conn$host$username$password$db_name3306NULLMYSQLI_CLIENT_SSL);

if (
mysqli_connect_errno($conn))
{
    die('Failed to connect to MySQL: '.mysqli_connect_error());
}
else
{
 die(
'Good to go');


But on CodeIgniter 4, gives me an Unable to connect to the database exception with this similar settings:

PHP Code:
public $default = [
 
'DSN'      => '',
 
'hostname' => 'myhost.mysql.database.azure.com',
 
'username' => 'user',
 
'password' => 'pass',
 
'database' => 'foo',
 
'DBDriver' => 'MySQLi',
 
'DBPrefix' => '',
 
'pConnect' => false,
 
'DBDebug'  => (ENVIRONMENT !== 'production'),
 
'charset'  => 'utf8mb4',
 
'DBCollat' => 'utf8mb4_unicode_ci',
 
'swapPre'  => '',
 
'encrypt' => array(
            'ssl_ca' => '',
            'ssl_verify' => false),
 
'compress' => false,
 
'strictOn' => false,
 
'failover' => [],
 
'port'    => 3306
]; 

What can i do?

Alredy did:
- ssl_verify to true
- ssl_ca pointing to a ca_cert, as shown in: https://docs.microsoft.com/en-us/azure/m...onnect-php
Reply
#2

Solved.
i've changed by myself the file /system/Database/MySQLi/Connection.php

From:
[Image: aVkQJ6J.png]

To:
[Image: G6745wQ.png]

Since if the "encrypt" array is set, this variable should be setted to use in mysql_real_connect.

Should i report on GitHub?
Reply
#3

yes please
Reply




Theme © iAndrew 2016 - Forum software by © MyBB