'SSL connection required for plugin "mysql_clear_password". Check if 'sslMode' is enabled

While connecting to Cloudsql DB via auth proxy from java application I am getting below error. Caused by: java.sql.SQLException: SSL connection required for plugin "mysql_clear_password". Check if 'sslMode' is enabled.

Not able to get through mysql docs the correct value to be set.

Has anyone faced similar issue ?

Below is the code for reference:

        String jdbcURL = String.format("jdbc:mysql://127.0.0.1:3306/%s", DB_NAME);
        Properties connProps = new Properties();
        connProps.setProperty("user", DB_USER);
        connProps.setProperty("password", DB_PASSWORD);
        connProps.setProperty("cloudSqlInstance", CONNECTION_NAME);
        connProps.setProperty("authenticationPlugins ", "com.mysql.jdbc.authentication.MysqlClearPasswordPlugin");
        HikariConfig config = new HikariConfig();
        config.setJdbcUrl(jdbcURL);


Solution 1:[1]

In this documentation, you can find how to modify MySQL accounts. You can use an ALTER USER statement to enable authentication, SSL/TLS, resource-limit, and password-management properties for existing accounts.

EDIT:

Additionally, since you cannot change anything on the DB/server side, you could try to pass sslMode="REQUIRED" flag along with JDBC connection.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1