无法通过SSL将Laravel连接到MySQL。 'PDO :: __ construct():此流不支持SSL /加密'

时间:2018-05-16 08:23:24

标签: mysql laravel-5 pdo openssl lumen

当我将配置添加到Laravel / Lumen以通过ssl连接到MySQL服务器时,我收到此错误。

2018-05-16 10:42:45] lumen.ERROR: exception 'ErrorException' with message 'PDO::__construct(): this stream does not support SSL/crypto' in /var/www/project/vendor/illuminate/database/Connectors/Connector.php:56

我检查了已安装的php模块。它显示openssl已安装php -m并且已安装php-mysqlnd

这是我的配置:

'mysql' => [
        'driver'    => 'mysql',
        'host'      => env('DB_HOST', 'localhost'),
        'port'      => env('DB_PORT', 3306),
        'database'  => env('DB_DATABASE', 'forge'),
        'username'  => env('DB_USERNAME', 'forge'),
        'password'  => env('DB_PASSWORD', ''),
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => env('DB_PREFIX', ''),
        'timezone'  => env('DB_TIMEZONE', '+00:00'),
        'strict'    => false,
        'options'   => array(
              PDO::MYSQL_ATTR_SSL_KEY => '/etc/ssl/certs/mysqlssl/key.pem',
              PDO::MYSQL_ATTR_SSL_CERT => '/etc/ssl/certs/mysqlssl/cert.pem',
              PDO::MYSQL_ATTR_SSL_CA => '/etc/ssl/certs/mysqlssl/ca-cert.pem',
    ),

并显示mysql正在运行ssl:

enter image description here

1 个答案:

答案 0 :(得分:0)

原来不能使用localhost或它不会使用TCP / IP,而是使用不使用SSL的unix套接字。