近期在跑一个项目的时候Idea的日志窗口出现了下面的警告,该警告对运行测试的结果没有影响,但是始终让人不舒服,也不知道有没有隐患,于是对该问题进行了了解和处理,警告内容如下:;

Thu Dec 20 12:50:09 CST 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.

翻译:

       不建议在没有服务器身份验证的情况下建立SSL连接,根据MySQL 5.5.45+、5.6.26+和5.7.6+的要求,如果没有设置显式选项,则必须默认建立SSL连接。为了符合不使用SSL的现有应用程序,verifyServerCertificate属性被设置为“false”。您需要通过设置useSSL=false显式禁用SSL,或者设置useSSL=true并为服务器证书验证提供信任存储。

        经过翻译后是不是很清晰了,不建议在没有服务器身份验证的情况下建立SSL连接,只是不建议,如果你执意这么做的话呢,当然可以无视,那么如果你接受了人家的建议,该怎么解决这个问题呢?很简单,在你连接数据库的url后面加上参数即可,例如:

   jdbc:mysql://localhost:3306/testdb?useSSL=false

使用上述标红的URL,即可解决该警告,标红参数前面为你数据库连接URL,如果有多个参数记得用&连接,例如

 jdbc:mysql://localhost:3306/testdb?characterEncoding=utf-8&useSSL=false

参考链接:运行项目连接Mysql时出现警告Establishing SSL connection without server‘s identity verification is not recommende_棒叔叔的博客-CSDN博客

更多推荐