Establishing SSL connection without server's identity verification is not recommended

1 前言

Java代码连接数据库,报如下警告

 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 有关,其实这种警告很容易出现,比如我们使用 Git 连接 Github 时如果没有配置密钥,也会报这种警告。解决办法也在上面提示了,或者使用 HTTPS 连接,如果没证书 也会报这种警告。

You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification

2 解决

配置 useSSL=false 在 连接 URL 中即可

?characterEncoding=utf-8&useSSL=false

ok 完成!!!

猜你喜欢

转载自blog.csdn.net/guozhaohui628/article/details/80177563