leafsphp / db

🗄 Leaf PHP db module
https://leafphp.dev/modules/db/
6 stars 11 forks source link

Problem in SSL connection through PDO #12

Open skverma618 opened 1 year ago

skverma618 commented 1 year ago

I tried connecting my local codebase with the remote database through PDO but its not working, after that I made some changes in core.php and created a function using mysqli, and now the connection is working.

I used the same connection variables and pem files for verification

inside connect function in core.php

I also tried directly writing the PDO code as follows:

           $clientCertPath = $_SERVER['DOCUMENT_ROOT'] . "/client-cert.pem";
            $clientKeyPath = $_SERVER['DOCUMENT_ROOT'] . "/client-key.pem";
            $caCertPath = $_SERVER['DOCUMENT_ROOT'] . "/server-ca.pem";

            // PDO Connection options for SSL
            $pdoOptions = array(
                \PDO::MYSQL_ATTR_SSL_CA => $caCertPath,
                \PDO::MYSQL_ATTR_SSL_KEY => $clientKeyPath,
                \PDO::MYSQL_ATTR_SSL_CERT => $clientCertPath,
                \PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false,
            );