Path does not chain with any of the trust anchors

青旅半醒 2023-10-18 13:56 135阅读 0赞

报错信息

  1. The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
  2. at sun.reflect.GeneratedConstructorAccessor34.newInstance(Unknown Source)
  3. at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
  4. at java.lang.reflect.Constructor.newInstance(Unknown Source)
  5. at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:59)
  6. at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:103)
  7. at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:149)
  8. at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:165)
  9. at com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:355)
  10. at com.mysql.cj.protocol.a.NativeAuthenticationProvider.negotiateSSLConnection(NativeAuthenticationProvider.java:789)
  11. at com.mysql.cj.protocol.a.NativeAuthenticationProvider.proceedHandshakeWithPluggableAuthentication(NativeAuthenticationProvider.java:499)
  12. at com.mysql.cj.protocol.a.NativeAuthenticationProvider.connect(NativeAuthenticationProvider.java:217)
  13. at com.mysql.cj.protocol.a.NativeProtocol.connect(NativeProtocol.java:1411)
  14. at com.mysql.cj.NativeSession.connect(NativeSession.java:165)
  15. at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:982)
  16. at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:852)
  17. ... 6 more
  18. Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
  19. at sun.security.ssl.Alerts.getSSLException(Unknown Source)
  20. at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
  21. at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
  22. at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
  23. at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
  24. at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
  25. at sun.security.ssl.Handshaker.processLoop(Unknown Source)
  26. at sun.security.ssl.Handshaker.process_record(Unknown Source)
  27. at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
  28. at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
  29. at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
  30. at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
  31. at com.mysql.cj.protocol.ExportControlled.performTlsHandshake(ExportControlled.java:213)
  32. at com.mysql.cj.protocol.StandardSocketFactory.performTlsHandshake(StandardSocketFactory.java:206)
  33. at com.mysql.cj.protocol.a.NativeSocketConnection.performTlsHandshake(NativeSocketConnection.java:99)
  34. at com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:350)
  35. ... 13 more
  36. Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
  37. at com.mysql.cj.protocol.ExportControlled$X509TrustManagerWrapper.checkServerTrusted(ExportControlled.java:280)
  38. at sun.security.ssl.AbstractTrustManagerWrapper.checkServerTrusted(Unknown Source)
  39. ... 25 more
  40. Caused by: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
  41. at sun.security.provider.certpath.PKIXCertPathValidator.validate(Unknown Source)
  42. at sun.security.provider.certpath.PKIXCertPathValidator.engineValidate(Unknown Source)
  43. at java.security.cert.CertPathValidator.validate(Unknown Source)
  44. at com.mysql.cj.protocol.ExportControlled$X509TrustManagerWrapper.checkServerTrusted(ExportControlled.java:273)
  45. ... 26 more

解决

不建议在没有服务器身份验证的情况下建立SSL连接。根据MySQL 5.5.45+、5.6.26+和5.7.6+的要求,

如果不设置显式选项,则必须建立默认的SSL连接。需要通过设置useSSL=false来显式禁用SSL,

或者设置useSSL=true并为服务器证书验证提供信任存储。

找到数据连接的url,这里是ssm整合时的配置文件中

将useSSL=true改为useSSL=false

  1. <!-- 定义数据源Bean -->
  2. <!-- Druid -->
  3. <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
  4. <property name="url"value="jdbc:mysql://localhost:3306/ssmtest?characterEncoding=UTF-8&useSSL=false" />
  5. <property name="username" value="root" />
  6. <property name="password" value="123" />
  7. </bean>

发表评论

表情:
评论列表 (有 0 条评论,135人围观)

还没有评论,来说两句吧...

相关阅读