JDBC连接一直告警WARN: Establishing SSL connection without server‘s identity verification is not recomme

问题:
最近在用jdbc操作数据库时,发现配置了jdbc参数以后,应用启动一直再打印告警信息,如下:

Fri Mar 30 14:55:35 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.

解决办法:
这行告警信息,不影响jdbc连接数据库查询数据,出现的原因就是高版本Mysql的url需要明确配置是否使用SSL协议,如下:jdbc:mysql://localhost:3306/test?useSSL=false或者useSSL=true。当然也可以配置全一点【jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false

url参数详解:
①useUnicode:是否使用unicode
②characterEncoding:字符编码格式
③useSSL:是否使用ssl协议

题外话:
SSL(Secure Sockets Layer 安全套接层),及其继任者传输层安全(Transport Layer Security,TLS)是为网络通信提供安全及数据完整性的一种安全协议。TLS与SSL在传输层对网络连接进行加密。SSL为Netscape所研发,用以保障在Internet上数据传输的安全,利用数据加密(Encryption)的技术,可确保数据在网络上的传输过程中不会被截取及窃听。SSL协议位于TCP/IP协议与各种应用层协议之间,为数据通讯提供安全支持。


版权声明:本文为github_34793283原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。