laravel-data-anonymization icon indicating copy to clipboard operation
laravel-data-anonymization copied to clipboard

Remote database with secure connection by certificate

Open v-trishyn opened this issue 3 years ago • 1 comments

SQLSTATE[HY000] [3159] Connections using insecure transport are prohibited while --require_secure_transport=ON.

The website is functioning alright, PHP-CLI also works fine, and tested the connection to DB with the tinker.

v-trishyn avatar Aug 21 '22 10:08 v-trishyn

Found and fixed it within the Database/SqlDatabase.php

    /**
     * Constructor.
     *
     * @param string     $dsn
     * @param string     $user
     * @param string     $password
     * @param null|array $options
     */
    public function __construct($dsn, $user, $password, $options = null)
    {
        if (is_null($options)) {
            $options = [
                PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
                PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
                PDO::MYSQL_ATTR_SSL_CA => 'some/ridiculous/filepath', // this is the really dirty fix, because the certificate will not be checked
                PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false // this is the really dirty fix, because the certificate will not be checked
            ];
        }

        $this->pdo = new PDO($dsn, $user, $password, $options);
    }

Too lazy to create a PR, sorry. Also seems this repo is dead.

v-trishyn avatar Aug 21 '22 14:08 v-trishyn