title: MySQL connection over SSL with Laravel
body: <p>I have a problem connecting to my database over ssl in a Laravel application. My config is as follows:</p>
  
  <pre><code>       'mysql' =&gt; [
              'driver' =&gt; 'mysql',
              'host' =&gt; env('DB_HOST', '127.0.0.1'),
              'port' =&gt; env('DB_PORT', '3306'),
              'database' =&gt; env('DB_DATABASE', 'forge'),
              'username' =&gt; env('DB_USERNAME', 'forge'),
              'password' =&gt; env('DB_PASSWORD', ''),
              'unix_socket' =&gt; env('DB_SOCKET', ''),
              'charset' =&gt; 'utf8mb4',
              'collation' =&gt; 'utf8mb4_unicode_ci',
              'prefix' =&gt; '',
              'strict' =&gt; true,
              'engine' =&gt; null,
              'sslmode' =&gt; 'require',
              'options'   =&gt; array(
                  PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT =&gt; false,
                  PDO::MYSQL_ATTR_SSL_KEY =&gt; '/certs/client-key.pem',
                  PDO::MYSQL_ATTR_SSL_CERT =&gt; '/certs/client-cert.pem',
                  PDO::MYSQL_ATTR_SSL_CA =&gt; '/certs/ca.pem',
              ),
          ],
  
  DB_CONNECTION=mysql
  DB_HOST=xxx.xxx.xxx.xxx
  DB_PORT=3306
  DB_DATABASE=db_name
  DB_USERNAME=db_user
  DB_PASSWORD=xxxx
  </code></pre>
  
  <p>These setting give me the following error on the MySQL server.</p>
  
  <pre><code>2018-10-30T09:18:25.403712Z 71 [Note] Access denied for user 'user'@'xxx.xxx.xxx.xxx' (using password: YES)
  </code></pre>
  
  <p>Through mysql-client it works perfectly from the client server.</p>
  
  <pre><code>mysql -u user -p -h xxx.xxx.xxx.xxx --ssl-ca=/certs/ca.pem --ssl-cert=/certs/client-cert.pem --ssl-key=/certs/client-key.pem
  </code></pre>
  
  <p>Output of `\s' command performed on the client while connected with the above command.</p>
  
  <pre><code>mysql  Ver 15.1 Distrib 10.1.26-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
  
  Connection id:      16
  Current database:   database
  Current user:       user@xxx.xxx.xxx.xxx
  SSL:            Cipher in use is DHE-RSA-AES256-SHA
  Current pager:      stdout
  Using outfile:      ''
  Using delimiter:    ;
  Server:         MySQL
  Server version:     5.7.24-0ubuntu0.18.10.1 (Ubuntu)
  Protocol version:   10
  Connection:     167.99.215.179 via TCP/IP
  Server characterset:    latin1
  Db     characterset:    latin1
  Client characterset:    utf8mb4
  Conn.  characterset:    utf8mb4
  TCP port:       3306
  Uptime:         23 min 29 sec
  
  Threads: 2  Questions: 38  Slow queries: 0  Opens: 135  Flush tables: 1  Open tables: 128  Queries per second avg: 0.026
  --------------
  </code></pre>
  
  <p>The application runs inside a docker container based on the <code>php:7.2.11-fpm</code> image. And is configured with the following php extensions.</p>
  
  <p><code>RUN docker-php-ext-install bcmath zip pdo_mysql json tokenizer</code></p>
  
  <p>MySQL version:</p>
  
  <pre><code>Server version: 5.7.24-0ubuntu0.18.10.1 (Ubuntu)
  </code></pre>
  
  <p>PHP version:</p>
  
  <pre><code>PHP 7.2.11 (cli) (built: Oct 16 2018 00:46:29) ( NTS )
  </code></pre>
  
  <p>PDO version:</p>
  
  <pre><code>PDO
  
  PDO support =&gt; enabled
  PDO drivers =&gt; sqlite, mysql
  
  pdo_mysql
  
  PDO Driver for MySQL =&gt; enabled
  Client API version =&gt; mysqlnd 5.0.12-dev - 20150407 - $Id: 38fea24f2847fa7519001be390c98ae0acafe387
  </code></pre>
  
  <p>OpenSSL version:</p>
  
  <pre><code>openssl
  
  OpenSSL support =&gt; enabled
  OpenSSL Library Version =&gt; OpenSSL 1.1.0f  25 May 2017
  OpenSSL Header Version =&gt; OpenSSL 1.1.0f  25 May 2017
  Openssl default config =&gt; /usr/lib/ssl/openssl.cnf
  
  Directive =&gt; Local Value =&gt; Master Value
  openssl.cafile =&gt; no value =&gt; no value
  openssl.capath =&gt; no value =&gt; no value
  </code></pre>
  
  <p>Any thoughts on this? This is keeping me busy for hours...</p>