perldbi

Encrypt database connection for perl and mysql using dbi


We are connecting to mysql database from perl using DBI. The connection string has dns as $dsn = "DBI:mysql:database=test;host=myhost.portal.com;port=3306;";. But this connection is made using cleartext. We want to encrypt connection.

Which parameter we have to pass to make sure connection between application and mysql are encrypted or secure?

I check, there is mysql_ssl parameter, but not sure, does this encrypt the database connection.


Solution

  • The docs seems to answer this directly:

    mysql_ssl
        A true value turns on the CLIENT_SSL flag when connecting to 
        the  MySQL server and enforce SSL encryption. ... This means that
        your communication with the server will be encrypted.
    

    perl5-dbi/DBD-mysql#110 is also interesting reading.