Skip to content

Commit b6bbb4b

Browse files
committed
[mysql] an attempt to support mysql/mysql2's config :sslxxx options
1 parent 17210c3 commit b6bbb4b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/arjdbc/mysql/connection_methods.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ def mysql_connection(config)
3737
# with reconnect fail-over sets connection read-only (by default)
3838
# properties['failOverReadOnly'] ||= 'false'
3939
end
40+
if config[:sslkey] || sslcert = config[:sslcert] # || config[:use_ssl]
41+
properties['useSSL'] ||= true
42+
properties['requireSSL'] ||= true
43+
properties['clientCertificateKeyStoreUrl'] ||= begin
44+
java.io.File.new(sslcert).to_url.to_s
45+
end if sslcert
46+
if sslca = config[:sslca]
47+
properties['trustCertificateKeyStoreUrl'] ||= begin
48+
java.io.File.new(sslca).to_url.to_s
49+
end
50+
else
51+
properties['verifyServerCertificate'] ||= false
52+
end
53+
end
4054

4155
jdbc_connection(config)
4256
end

0 commit comments

Comments
 (0)