php-crud-api icon indicating copy to clipboard operation
php-crud-api copied to clipboard

Specify options for database connection in configuration

Open galletl opened this issue 3 years ago • 2 comments

Hello.

I want connect php-crud-api on MariaDB who accepts TLS connections only. It's work if, in PHP code, I modify the function "getOptions" for adding those lines in mysql options block :

\PDO::MYSQL_ATTR_SSL_CAPATH => '/etc/ssl/certs',
\PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => true,

There is a way to specify options for database connection in configuration ?

galletl avatar Oct 21 '22 08:10 galletl

Currently the options aren't configurable, the commands are. I registered this as a feature request to make them configurable. In the meantime you can search for PDO::MYSQL_ATTR_FOUND_ROWS and add these options in the 'getOptions' method as a workaround. I'll keep this issue open as a feature request.

mevdschee avatar Oct 21 '22 16:10 mevdschee

You might be able to workaround this limitation using stunnel as client, see: https://www.stunnel.org/

  • https://serverfault.com/questions/262484/connecting-to-mysql-securely-mysqls-ssl-vs-stunnel-vs-ssh-tunneling
  • https://www.digitalocean.com/community/tutorials/how-to-set-up-an-ssl-tunnel-using-stunnel-on-ubuntu
  • https://www.percona.com/blog/mysql-encryption-performance-revisited/

I have found that somebody was trying to use stunnel in client mode for mysql and failed, see:

  • https://forums.mysql.com/read.php?30,620633,620633#msg-620633

If you succeed, please let us know. I hope this helps. Kind regards, Maurits

NB: Do consider SSH tunnels (that's what I use), as they are more secure and faster.

mevdschee avatar Jul 12 '23 06:07 mevdschee