Skip to content
This repository
Browse code

Added options to specify an SSL connection for MySQL. Define the foll…

…owing attributes in the connection config (config/database.yml in Rails) to use it: sslkey, sslcert, sslca, sslcapath, sslcipher. To use SSL with no client certs, just set :sslca = /dev/null. http://dev.mysql.com/doc/mysql/en/secure-connections.html #604 [daniel@nightrunner.com]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@720 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit ba309a3e38297dfb79fa574555a1b8a003b04d1a 1 parent 101968f
David Heinemeier Hansson authored February 20, 2005
2  activerecord/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *SVN*
2 2
 
  3
+* Added options to specify an SSL connection for MySQL. Define the following attributes in the connection config (config/database.yml in Rails) to use it: sslkey, sslcert, sslca, sslcapath, sslcipher. To use SSL with no client certs, just set :sslca = '/dev/null'. http://dev.mysql.com/doc/mysql/en/secure-connections.html #604 [daniel@nightrunner.com]
  4
+
3 5
 * Added automatic dropping/creating of test tables for running the unit tests on all databases #587 [adelle@bullet.net.au]
4 6
 
5 7
 * Fixed that find_by_* would fail when column names had numbers #670 [demetrius]
10  activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -3,7 +3,7 @@
3 3
 
4 4
 module ActiveRecord
5 5
   class Base
6  
-    # Establishes a connection to the database that's used by all Active Record objects
  6
+    # Establishes a connection to the database that's used by all Active Record objects.
7 7
     def self.mysql_connection(config) # :nodoc:
8 8
       unless self.class.const_defined?(:Mysql)
9 9
         begin
@@ -19,7 +19,9 @@ def self.mysql_connection(config) # :nodoc:
19 19
           end
20 20
         end
21 21
       end
  22
+
22 23
       symbolize_strings_in_hash(config)
  24
+
23 25
       host     = config[:host]
24 26
       port     = config[:port]
25 27
       socket   = config[:socket]
@@ -32,9 +34,9 @@ def self.mysql_connection(config) # :nodoc:
32 34
         raise ArgumentError, "No database specified. Missing argument: database."
33 35
       end
34 36
 
35  
-      ConnectionAdapters::MysqlAdapter.new(
36  
-        Mysql::real_connect(host, username, password, database, port, socket), logger
37  
-      )
  37
+      mysql = Mysql.init
  38
+      mysql.ssl_set(config[:sslkey], config[:sslcert], config[:sslca], config[:sslcapath], config[:sslcipher]) if config[:sslkey]
  39
+      ConnectionAdapters::MysqlAdapter.new(mysql.real_connect(host, username, password, database, port, socket), logger)
38 40
     end
39 41
   end
40 42
 

0 notes on commit ba309a3

Please sign in to comment.
Something went wrong with that request. Please try again.