Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure ssl is enabled if only :sslverify is set #889

Merged
merged 1 commit into from
Nov 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/mysql2/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def initialize(opts = {})
self.charset_name = opts[:encoding] || 'utf8'

ssl_options = opts.values_at(:sslkey, :sslcert, :sslca, :sslcapath, :sslcipher)
ssl_set(*ssl_options) if ssl_options.any?
ssl_set(*ssl_options) if ssl_options.any? || opts.key?(:sslverify)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will turn on ssl even if the only flag is sslverify: false which doesn't quite make sense to me.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think given #879 that ssl_set should be called if any value of :ssl_mode is set, too.

self.ssl_mode = parse_ssl_mode(opts[:ssl_mode]) if opts[:ssl_mode]

case opts[:flags]
Expand All @@ -62,7 +62,7 @@ def initialize(opts = {})
end

# SSL verify is a connection flag rather than a mysql_ssl_set option
flags |= SSL_VERIFY_SERVER_CERT if opts[:sslverify] && ssl_options.any?
flags |= SSL_VERIFY_SERVER_CERT if opts[:sslverify]

if [:user, :pass, :hostname, :dbname, :db, :sock].any? { |k| @query_options.key?(k) }
warn "============= WARNING FROM mysql2 ============="
Expand Down