public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Ensure MysqlAdapter allows SSL connection when only sslca is supplied. [#253 
state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Micah Wedemeyer (author)
Fri Jul 11 15:50:55 -0700 2008
lifo (committer)
Fri Jul 11 15:52:41 -0700 2008
commit  5e2e1ed9ffc481a91596d8c3fd9a68d7977e75ca
tree    e47b8f9692a8ad4bc7da74d21943bc076184bc7d
parent  6ebdd0e32b846e99a9885b06fbca2bed58149c7e
...
69
70
71
72
 
73
74
75
...
145
146
147
 
148
149
150
...
507
508
509
510
 
 
 
511
512
513
...
69
70
71
 
72
73
74
75
...
145
146
147
148
149
150
151
...
508
509
510
 
511
512
513
514
515
516
0
@@ -69,7 +69,7 @@ module ActiveRecord
0
       MysqlCompat.define_all_hashes_method!
0
 
0
       mysql = Mysql.init
0
-      mysql.ssl_set(config[:sslkey], config[:sslcert], config[:sslca], config[:sslcapath], config[:sslcipher]) if config[:sslkey]
0
+      mysql.ssl_set(config[:sslkey], config[:sslcert], config[:sslca], config[:sslcapath], config[:sslcipher]) if config[:sslca] || config[:sslkey]
0
 
0
       ConnectionAdapters::MysqlAdapter.new(mysql, logger, [host, username, password, database, port, socket], config)
0
     end
0
@@ -145,6 +145,7 @@ module ActiveRecord
0
     # * <tt>:password</tt> - Defaults to nothing.
0
     # * <tt>:database</tt> - The name of the database. No default, must be provided.
0
     # * <tt>:encoding</tt> - (Optional) Sets the client encoding by executing "SET NAMES <encoding>" after connection.
0
+    # * <tt>:sslca</tt> - Necessary to use MySQL with an SSL connection.
0
     # * <tt>:sslkey</tt> - Necessary to use MySQL with an SSL connection.
0
     # * <tt>:sslcert</tt> - Necessary to use MySQL with an SSL connection.
0
     # * <tt>:sslcapath</tt> - Necessary to use MySQL with an SSL connection.
0
@@ -507,7 +508,9 @@ module ActiveRecord
0
             @connection.options(Mysql::SET_CHARSET_NAME, encoding) rescue nil
0
           end
0
 
0
-          @connection.ssl_set(@config[:sslkey], @config[:sslcert], @config[:sslca], @config[:sslcapath], @config[:sslcipher]) if @config[:sslkey]
0
+          if @config[:sslca] || @config[:sslkey]
0
+            @connection.ssl_set(@config[:sslkey], @config[:sslcert], @config[:sslca], @config[:sslcapath], @config[:sslcipher])
0
+          end
0
 
0
           @connection.real_connect(*@connection_options)
0
 

Comments