Description
Hello!
I would like to ask if there's a plan to support sslMode
configuration for MySQL database? According to FAQ, currently, only PostgreSQL is supported. I also noticed that com.github.jasync.sql.db.SSLConfiguration
defaults to sslMode=disabled
mode for MySQL which leads to problems when the MySQL Server is configured to enforce SSL connections.
I had a look at the implementation details and found that this library integrates with R2DBC SPI (https://r2dbc.io/spec/0.8.1.RELEASE/spec/html/#overview.connection.discovery). The driver will be discovered by R2DBC SPI which will use com.github.jasync.r2dbc.mysql.MysqlConnectionFactoryProvider#create
to create io.r2dbc.spi.ConnectionFactory
object:
// from: com.github.jasync.r2dbc.mysql.MysqlConnectionFactoryProvider#create
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
override fun create(connectionFactoryOptions: ConnectionFactoryOptions): JasyncConnectionFactory {
val configuration = Configuration(
host = connectionFactoryOptions.getValue(HOST),
port = connectionFactoryOptions.getValue(PORT),
username = connectionFactoryOptions.getValue(USER),
password = connectionFactoryOptions.getValue(PASSWORD)?.toString(),
database = connectionFactoryOptions.getValue(DATABASE),
applicationName = connectionFactoryOptions.getValue(APPLICATION_NAME),
connectionTimeout = connectionFactoryOptions.getValue(CONNECT_TIMEOUT)?.toMillis()?.toInt() ?: 5000,
queryTimeout = connectionFactoryOptions.getValue(QUERY_TIMEOUT)
)
return JasyncConnectionFactory(MySQLConnectionFactory(configuration))
}
The above method does not configure com.github.jasync.sql.db.SSLConfiguration
and thus, the default sslMode
(Mode.Disable
) will be used. Even though, the connectionFactoryOptions
could have the option ssl
set to true
or any sslMode
parameter specified.
I suspect that changing this factory to interpret the ssl
and sslMode
parameter of connectionFactoryOptions
would quickly resolve the issue. It seems that com.github.jasync.sql.db.mysql.MySQLConnection#onHandshake
already supports SSL.
I would be happy to contribute and resolve this issue. But first I would like to make sure:
- Is my understanding of current implementation described above correct?
- The ssl option in
connectionFactoryOptions
would return true in case the secure protocol (r2dbcs
) is used. However how should it handle the combination of secure protocol andsslMode=disabled
, for example through the following connection string:r2dbcs:mysql://example.com?sslMode=disabled
? - Should my contribution also support other MySQL parameters. If so, would anyone be able to specify which? I know there are legacy parameters like 'useSSL', 'requireSSL', and 'verifyServerCertificate' which are still accepted but translated into a value for 'sslMode' by MySQL Server. The
com.github.jasync.sql.db.SSLConfiguration
also acceptssslrootcert
,sslcert
,sslkey
.
Thanks!