Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable WARN when connecting to SQL database in Java

Tags:

java

mysql

ssl

In a Java application I'm programming, when I ask the program to retrieve data from an SQL database, it shows this in console :

Wed Apr 20 16:57:58 MDT 2016 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.

I know that's a lot to read, and I have SSL disabled in the SQL workbench, so I can't figure out how to get rid of the warning or if I should even be concerned about it? Thanks in advance.

like image 867
Ethan Moore Avatar asked Apr 20 '16 23:04

Ethan Moore


People also ask

How do you explicitly disable SSL by setting useSSL false?

You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. If you want to avoid the above MySQL warning, use the syntax mention in the beginning.

How disable SSL in MySQL?

Disabling SSL in MySQL If your requirement is to completely turn off SSL on MySQL server instead of the default option of 'enabled, but optional mode', we can do the following: Delete the *. pem certificate and key files in the MySQL data directory. Start MySQL with SSL option turned off.

How do I disable SSL in SQL Workbench?

mysql/workbench/connections. xml , look for the connection that you want to disable ssl, and find <value type="int" key="useSSL">2</value> set it to 0, that will disable ssl for that connection.

What is the use of useSSL?

5 and earlier, in which case the client must set the connection property useSSL=true in order to use encrypted connections). The client can demand SSL to be used by setting the connection property requireSSL=true ; the connection then fails if the server is not configured to use SSL.


2 Answers

Try to use the useSSL=false in the connection string

Example:

jdbc:mysql://xxxxxxx:3306/xxxx?autoReconnect=true&useSSL=false

EDIT:

I had issue today 11/20/2019 while connecting mysql version 8.0.12 using java mysql driver (com.mysql.cj.jdbc.Driver, 8.0.18) and got following error

Exception in thread "main" java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed

I had to add allowPublicKeyRetrieval=true to connection string to fix the connection issue.

Updated this answer because its related issue :)

like image 177
geek Avatar answered Oct 21 '22 14:10

geek


Replace – jdbc:mysql://localhost:3306/demo

With – jdbc:mysql://localhost:3306/demo?useSSL=false

like image 22
William Guzman Avatar answered Oct 21 '22 12:10

William Guzman