Skip to content

Commit

Permalink
Ensure MysqlAdapter allows SSL connection when only sslca is supplied. [
Browse files Browse the repository at this point in the history
#253 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information
Micah Wedemeyer authored and lifo committed Jul 11, 2008
1 parent 6ebdd0e commit 5e2e1ed
Showing 1 changed file with 5 additions and 2 deletions.
Expand Up @@ -69,7 +69,7 @@ def self.mysql_connection(config) # :nodoc:
MysqlCompat.define_all_hashes_method!

mysql = Mysql.init
mysql.ssl_set(config[:sslkey], config[:sslcert], config[:sslca], config[:sslcapath], config[:sslcipher]) if config[:sslkey]
mysql.ssl_set(config[:sslkey], config[:sslcert], config[:sslca], config[:sslcapath], config[:sslcipher]) if config[:sslca] || config[:sslkey]

ConnectionAdapters::MysqlAdapter.new(mysql, logger, [host, username, password, database, port, socket], config)
end
Expand Down Expand Up @@ -145,6 +145,7 @@ def missing_default_forged_as_empty_string?(default)
# * <tt>:password</tt> - Defaults to nothing.
# * <tt>:database</tt> - The name of the database. No default, must be provided.
# * <tt>:encoding</tt> - (Optional) Sets the client encoding by executing "SET NAMES <encoding>" after connection.
# * <tt>:sslca</tt> - Necessary to use MySQL with an SSL connection.
# * <tt>:sslkey</tt> - Necessary to use MySQL with an SSL connection.
# * <tt>:sslcert</tt> - Necessary to use MySQL with an SSL connection.
# * <tt>:sslcapath</tt> - Necessary to use MySQL with an SSL connection.
Expand Down Expand Up @@ -507,7 +508,9 @@ def connect
@connection.options(Mysql::SET_CHARSET_NAME, encoding) rescue nil
end

@connection.ssl_set(@config[:sslkey], @config[:sslcert], @config[:sslca], @config[:sslcapath], @config[:sslcipher]) if @config[:sslkey]
if @config[:sslca] || @config[:sslkey]
@connection.ssl_set(@config[:sslkey], @config[:sslcert], @config[:sslca], @config[:sslcapath], @config[:sslcipher])
end

@connection.real_connect(*@connection_options)

Expand Down

0 comments on commit 5e2e1ed

Please sign in to comment.