Home » Quick Tips

Secure Database Connections In Drupal

Posted 24 Sep 2009 | No Comments | 315 views
Drupal Filler Panel

If you are setting up a Drupal site with an SSL certificate in a shared environment such as an ISP or hosting center, one of the things that you need to consider is the connectivity to your database. If you database is running locally on the server, then protecting your database is easy.  Configure it to listen on a socket, and configure your firewall appropriately.

If your database is running on another server, then the database connections should also use SSL. (Following the age old adage: Encryption in the front, encryption in the back.) This will ensure data in transit is protected end-to-end.

Unfortunately, there is no check box to turn SSL connections on to a MySQL database, but the fix is easy to make. In the includes/install.mysql.inc and includes/database.mysql.inc, look for the following line (just look for mysql_connect):

$connection = @mysql_connect($url['host'], $url['user'], $url['pass'], TRUE, 2);

Change the line to look like this:

$connection = @mysql_connect($url['host'], $url['user'], $url['pass'], TRUE, 2050);

That’s basically all there is to it.  When issuing the GRANT statements, be sure to add REQUIRE SSL to the end of the SQL statement.

Related Posts

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4.00 out of 5)
Loading ... Loading ...

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS. Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled service. To get your own globally-recognized-avatar, please register at Gravatar.

*