How do I connect to a MySQL database over SSL with Laravel 5.3

后端 未结 3 1921
难免孤独
难免孤独 2020-12-20 08:38

I\'ve been searching all over the internet and haven\'t had any success.

eg: https://laravel.io/forum/06-18-2014-connecting-mysql-over-ssl?page=1 https://laracasts

3条回答
  •  借酒劲吻你
    2020-12-20 08:50

    Ok. Solved the issue. Hopped on the phone with microsoft and noticed one of the log errors was:

    PDO::__construct(): Peer certificate CN=`resourceregion-a.control.database.windows.net' did not match expected CN=`db.mysql.database.azure.com'
    

    And that line in the documentation that @alexejenko points out, the bit after that:

    " If you require to use "--ssl-mode=VERIFY_IDENTITY", then you can ping your server name to resolve the regional server name, such as westeurope1-a.control.database.windows.net, and use that regional server name in the connection until this issue is resolved. We plan to remove this limitation in the future."

    Turns out this is what was happening. The database connection was routing to the regional database, not mine. So yay for not quite finished products.

    Once I changed my DB_HOST to that region it successfully connected (note: make sure you've whitelisted your ips).

提交回复
热议问题