Database/MySQL

[MySQL] Establishing SSL connection without server's identity verification is not recommended.

꽁담 2018. 7. 4. 23:49

JDBC 로 MySQL 연동 시, 다음과 같은 메세지가 출력되는 경우가 있습니다.


WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.


위 메세지는 에러는 아니지만, 출력되는게 껄끄러우므로 URL 옵션에 useSSL=false 옵션을 부여하여 출력하지 않을 수 있습니다.



JDBC useSSL=false 옵션이 없는경우

import java.sql.*; import javax.sql.*; public class Main { protected static final String MYSQL_DRIVER_CLASS = "com.mysql.jdbc.Driver"; protected static final String URL_BASIC = "jdbc:mysql://192.168.0.136:3306/mysql"; public static Connection createConnectionByDriverManager(String id, String password) throws SQLException { try { Class.forName(MYSQL_DRIVER_CLASS); } catch (ClassNotFoundException sException) { } return DriverManager.getConnection(URL_BASIC, id, password); } public static void main(String[] args) throws Exception { Connection con = createConnectionByDriverManager("TEST", "test"); System.out.println("Connection Success"); con.close(); } }

$ java Main
Wed Jul 04 23:44:36 KST 2018 WARN: Establishing SSL connection without server's
identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+
requirements SSL connection must be established by default if explicit option isn't set.
For compliance with existing applications not using SSL the verifyServerCertificate property
is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false,
or set useSSL=true and provide truststore for server certificate verification.
Connection Success



JDBC useSSL=false 옵션이 있는 경우

import java.sql.*; import javax.sql.*; public class Main { protected static final String MYSQL_DRIVER_CLASS = "com.mysql.jdbc.Driver"; protected static final String URL_BASIC = "jdbc:mysql://192.168.0.136:3306/mysql?useSSL=false"; public static Connection createConnectionByDriverManager(String id, String password) throws SQLException { try { Class.forName(MYSQL_DRIVER_CLASS); } catch (ClassNotFoundException sException) { } return DriverManager.getConnection(URL_BASIC, id, password); } public static void main(String[] args) throws Exception { Connection con = createConnectionByDriverManager("TEST", "test"); System.out.println("Connection Success"); con.close(); } }

$ java Main
Connection Success