diff --git a/chef/cookbooks/database/libraries/provider_database_mysql.rb b/chef/cookbooks/database/libraries/provider_database_mysql.rb index 8f329e16a6..a492d0c5a8 100644 --- a/chef/cookbooks/database/libraries/provider_database_mysql.rb +++ b/chef/cookbooks/database/libraries/provider_database_mysql.rb @@ -74,13 +74,21 @@ def schema_present?(database_name) end def client - @client ||= Mysql2::Client.new( + client_options = { host: new_resource.connection[:host], socket: new_resource.connection[:socket], username: new_resource.connection[:username], password: new_resource.connection[:password], port: new_resource.connection[:port] - ) + } + if new_resource.connection[:ssl][:enabled] + if new_resource.connection[:ssl][:insecure] + client_options[:sslverify] = false + else + client_options[:sslca] = new_resource.connection[:ssl][:ca_certs] + end + end + @client ||= Mysql2::Client.new(client_options) end def close_client diff --git a/chef/cookbooks/database/libraries/provider_database_mysql_user.rb b/chef/cookbooks/database/libraries/provider_database_mysql_user.rb index 22b55a62db..71858e7096 100644 --- a/chef/cookbooks/database/libraries/provider_database_mysql_user.rb +++ b/chef/cookbooks/database/libraries/provider_database_mysql_user.rb @@ -111,13 +111,21 @@ def user_present?(username, host) end def client - @client ||= Mysql2::Client.new( + client_options = { host: new_resource.connection[:host], socket: new_resource.connection[:socket], username: new_resource.connection[:username], password: new_resource.connection[:password], port: new_resource.connection[:port] - ) + } + if new_resource.connection[:ssl][:enabled] + if new_resource.connection[:ssl][:insecure] + client_options[:sslverify] = false + else + client_options[:sslca] = new_resource.connection[:ssl][:ca_certs] + end + end + @client ||= Mysql2::Client.new(client_options) end def close_client