警告解决:Establishing SSL connection without server‘s identity verification is not recommended. Accordin

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: 警告解决:Establishing SSL connection without server‘s identity verification is not recommended. Accordin

进行需要连接数据库的操作时,控制台会报下面这个警告,看着不舒服,所以可以解决一下,你可以直接看英文,也能够看得懂。


Sun May 09 21:49:05 GMT+08:00 2021 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来为服务器证书验证提供信任存储。


简单的来说, 就是需要设置一下useSSL,你可以设置为false来禁用SSL,或者设置为true来使用SSL,报这个警告的原因主要是JDBC的版本与MySQL的版本不兼容,而MySQL在高版本需要指明是否进行SSL连接。


辅助阅读:

   SSL协议提供服务主要:     
       1)认证用户服务器,确保数据发送到正确的服务器;    .
       2)加密数据,防止数据传输途中被窃取使用;
       3)维护数据完整性,验证数据在传输过程中是否丢失;
   当前支持SSL协议两层:
      SSL记录协议(SSL Record Protocol):建立靠传输协议(TCP)高层协议提供数据封装、压缩、加密等基本功能支持
      SSL握手协议(SSL Handshake Protocol):建立SSL记录协议用于实际数据传输始前通讯双进行身份认证、协商加密
      算法、 交换加密密钥等。


解决办法:


在MySQL连接字符串的url中加上配置即可,比如:

spring.datasource.url=jdbc:mysql://localhost:3306/shaonaiyi?characterEncoding=UTF8&autoReconnect=true&useSSL=true


注意:低版本的MySQL使用useSSL=true可能会报错,使用useSSL=false不会报错,可以自行找资料解决。


报错样子如下:

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors


作用:

当配置MySQL端口为SSL,数据通道会加密处理,这样可以避免敏感信息泄漏和被篡改。

但是,启用MySQL的SSL之后,因为每个数据包都需要加密和解密,所以会对MySQL的性能产生不小的影响,大家在使用的时候,可以根据实际情况看是否要开启。

相关文章
|
3月前
|
人工智能 网络安全 开发工具
视觉智能开放平台操作报错合集之服务部署在pdd的服务器,调用报错:The SSL connection could not be established,该如何解决
在使用视觉智能开放平台时,可能会遇到各种错误和问题。虽然具体的错误代码和消息会因平台而异,但以下是一些常见错误类型及其可能的原因和解决策略的概述,包括但不限于:1. 认证错误、2. 请求参数错误、3. 资源超限、4. 图像质量问题、5. 服务不可用、6. 模型不支持的场景、7. 网络连接问题,这有助于快速定位和解决问题。
|
26天前
|
NoSQL 安全 网络安全
【Azure Redis】PHPRedis遇见SSL Connection Timeout问题
【Azure Redis】PHPRedis遇见SSL Connection Timeout问题
【Azure Redis】PHPRedis遇见SSL Connection Timeout问题
|
1月前
|
SQL 安全 Java
驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“The server selected protocol version TLS10 is not accepted by client
驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“The server selected protocol version TLS10 is not accepted by client
177 0
|
1月前
|
Android开发
解决Android、Flutter编译时Gradle报错:javax.net.ssl.SSLException: Connection reset
解决Android、Flutter编译时Gradle报错:javax.net.ssl.SSLException: Connection reset
144 0
|
4月前
|
网络安全 开发工具 git
解决 OpenSSL SSL_read: Connection was reset, errno 10054的问题
解决 OpenSSL SSL_read: Connection was reset, errno 10054的问题
|
10月前
|
开发工具 git
OpenSSL SSL_connect: Connection was reset in connection to github.com:443
OpenSSL SSL_connect: Connection was reset in connection to github.com:443
162 0
|
11月前
|
应用服务中间件 网络安全 nginx
nginx开启ssl报错: [emerg] "server" directive is not allowed here ...
nginx开启ssl报错: [emerg] "server" directive is not allowed here ...
277 0
|
3月前
|
安全 网络安全
如何给网站添加ssl安全证书
如何给网站添加ssl安全证书
81 1
|
3天前
|
运维 安全 数据建模
阿里云SSL证书收费版和免费版SSL有什么区别?全方位对比
阿里云提供免费和个人测试(Pro)及正式版SSL证书。免费版有效期仅3个月,适合个人网站或测试使用;个人测试(Pro)版68元/年,有效期12个月;正式版价格数百至数千元不等,有效期至少1年,支持DV、OV、EV证书类型,具有高安全等级、良好兼容性、稳定OCSP验证、SLA保障及安全保险赔付等优势,并提供最长3年的服务周期与人工客服支持。详情与报价参见SSL官方页面。
56 20
|
17天前
|
运维 安全 数据建模
阿里云免费SSL证书和收费版SSL证书有什么区别?
阿里云提供免费与收费SSL证书,前者有效期仅3个月,适合个人网站或测试使用;后者有效期至少1年,具备更高安全等级、良好兼容性及OCSP验证稳定性等优势,适用于企业网站,尤其政府、金融等领域建议选用OV或EV型证书以确保数据与身份认证安全。详细了解与报价请访问SSL证书官方页面。
116 2