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

How to add MYSQL_ATTR_SSL_CA option? #296

Open
duje13 opened this issue Jul 30, 2023 · 1 comment
Open

How to add MYSQL_ATTR_SSL_CA option? #296

duje13 opened this issue Jul 30, 2023 · 1 comment

Comments

@duje13
Copy link

duje13 commented Jul 30, 2023

Hi,

Usually database platforms (such as PlanetScale or TiDB Cloud) do not allow to connect without SSL/TLS. So, to be able to connect I need to set PDO::MYSQL_ATTR_SSL_CA attribute. My application is Symfony, so I do it on Symfony way by setting it in doctrine.yaml config file. But I don't know how to do it for TNT?

This is how I setup TNT currently:

//$dbUrl is env variable, DATABASE_URL="mysql://user:password@host:port/db_name"
$this->dbUrl = parse_url($dbUrl);
$tntConfig = [
            "driver" => $dbUrl["scheme"],
            "host" => $dbUrl["host"] . ":" . $dbUrl["port"],
            "database" => substr($dbUrl["path"], 1),
            "username" => $dbUrl["user"],
            "password" => $dbUrl["pass"],
            "storage" => "my/tnt/output/path,
            "stemmer" => PorterStemmer::class, 
];

$this->tntObject = new TNTSearch();
$this->tntObject->loadConfig($tntConfig);

Can I somehow add additional options (MYSQL_ATTR_SSL_CA in my case) to config? Or is there any other way to make TNT be able to connect to MySQL using SSL/TLS.

@duje13
Copy link
Author

duje13 commented Aug 2, 2023

Hi,

I found solution. It is possible to add custom PDO and give it to TNT with setDatabaseHandle method.

This solution works for me, but this solution feels kind of hack, more proper way would be if you can set it via loadConfig. Is that possible? If not, I think possibility to add this (or any other MySql attribute) should be added.

Anyway, I suggest to update documentation about this. Connecting via SSL seems too me like common use case and it not so straight forward to not being mention anywhere.

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