vendredi 14 septembre 2018

Laravel SSL connection to MySQL not working

I'm working on a project where I have to use SSL to connect to the MySQL database. This is working in vanilla PHP, but not when I try to use Laravel.

Working PHP-code:

<?php
$host = 'xxx';
$db = 'xxx';
$user = 'xxx';
$pass = 'xxx';
$charset = 'utf8';

$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$options = [
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
    PDO::ATTR_EMULATE_PREPARES => false,
    PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false,
    PDO::MYSQL_ATTR_SSL_CA => "../rootCA.pem",
];

try {
    $pdo = new PDO($dsn, $user, $pass, $options);
} catch (\PDOException $e) {
    throw new \PDOException($e->getMessage(), (int)$e->getCode());
}

$data = $pdo->query('SELECT * FROM x LIMIT 100')->fetchAll(PDO::FETCH_ASSOC);
var_export($data);

But when I try to connect via Laravel, then i get the following error:

C:\*\*\vendor\laravel\framework\src\Illuminate\Database\Connection.php on line 330
[Fri Sep 14 11:35:05 2018] ::1:54869 [500]: /data - Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes) in C:\*\*\vendor\laravel\framework\src\Illuminate\Database\Connection.php on line 330

My Laravel (5.7) config for the connection:

    'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', 'xxx'),
        'port' => env('DB_PORT', 'xxx'),
        'database' => env('DB_DATABASE', 'xxx'),
        'username' => env('DB_USERNAME', 'xxx'),
        'password' => env('DB_PASSWORD', ''),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix' => '',
        'strict' => false,
        'engine' => null,
        'options' => array(
            PDO::MYSQL_ATTR_SSL_CA  => '../rootCA.pem',
            PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false
        ),
    ],

Any ideas? =)



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2NKxUtm
via IFTTT

Aucun commentaire:

Enregistrer un commentaire