Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php-activerecord SSL (MariaDB / MySQL) #609

Open
kaizirlewagen opened this issue Dec 2, 2020 · 1 comment
Open

php-activerecord SSL (MariaDB / MySQL) #609

kaizirlewagen opened this issue Dec 2, 2020 · 1 comment

Comments

@kaizirlewagen
Copy link

We use the files from the master branch, with PHP7.4

Our MariaDB server is configured for SSL. SSL client connections are working.

Is php-activerecord able to use SSL for the MariaDB connection?

@kaizirlewagen
Copy link
Author

kaizirlewagen commented Dec 3, 2020

$cfg = ActiveRecord\Config::instance();
$cfg->set_model_directory('../src/models');
$cfg->set_connections($db_connections);

ActiveRecord\Config::initialize(function($cfg)
{
  $cfg->set_default_connection(DEFAULT_DB_CONN);
});

ActiveRecord\Connection::$PDO_OPTIONS[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES \'UTF8\'';
ActiveRecord\Connection::$PDO_OPTIONS[PDO::MYSQL_ATTR_SSL_KEY] = '../ssl/client-key.pem';
ActiveRecord\Connection::$PDO_OPTIONS[PDO::MYSQL_ATTR_SSL_CERT] = '../ssl/client-cert.pem';
ActiveRecord\Connection::$PDO_OPTIONS[PDO::MYSQL_ATTR_SSL_CA] = '../ssl/ca-cert.pem';
ActiveRecord\Connection::$PDO_OPTIONS[PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT] = false;

If some one needs it. Works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant