与RDS的Springboot连接会引发异常“由以下原因引起:java.security.cert.CertificateExpiredException:NotAfter:Fri Mar 06 00:54:04 EAT 2020”

问题描述 投票:0回答:1

我的应用程序突然开始抛出此异常时正在连接到AMAZON RDS

    2020-03-06 11:08:41.866  INFO 20878 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
    2020-03-06 11:08:52.791 ERROR 20878 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Exception during pool initialization.

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:na]
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) ~[na:na]
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481) ~[na:na]
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
    at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
    at com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:338) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
    at com.mysql.cj.protocol.a.NativeAuthenticationProvider.negotiateSSLConnection(NativeAuthenticationProvider.java:777) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
    at com.mysql.cj.protocol.a.NativeAuthenticationProvider.proceedHandshakeWithPluggableAuthentication(NativeAuthenticationProvider.java:486) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
    at com.mysql.cj.protocol.a.NativeAuthenticationProvider.connect(NativeAuthenticationProvider.java:202) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
    at com.mysql.cj.protocol.a.NativeProtocol.connect(NativeProtocol.java:1340) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
    at com.mysql.cj.NativeSession.connect(NativeSession.java:157) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
    at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:956) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
    ... 56 common frames omitted
Caused by: javax.net.ssl.SSLHandshakeException: NotAfter: Thu Mar 05 21:54:04 GMT 2020
    at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131) ~[na:na]
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:324) ~[na:na]
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:267) ~[na:na]
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:262) ~[na:na]
    at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:641) ~[na:na]
    at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.onCertificate(CertificateMessage.java:460) ~[na:na]
    at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(CertificateMessage.java:360) ~[na:na]
    at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:396) ~[na:na]
    at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:444) ~[na:na]
    at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:422) ~[na:na]
    at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:181) ~[na:na]
    at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:164) ~[na:na]
    at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1460) ~[na:na]
    at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1368) ~[na:na]
    at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:437) ~[na:na]
    at com.mysql.cj.protocol.ExportControlled.performTlsHandshake(ExportControlled.java:336) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
    at com.mysql.cj.protocol.StandardSocketFactory.performTlsHandshake(StandardSocketFactory.java:188) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
    at com.mysql.cj.protocol.a.NativeSocketConnection.performTlsHandshake(NativeSocketConnection.java:99) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
    at com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:329) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
    ... 63 common frames omitted
Caused by: java.security.cert.CertificateExpiredException: NotAfter: Thu Mar 05 21:54:04 GMT 2020
    at java.base/sun.security.x509.CertificateValidity.valid(CertificateValidity.java:274) ~[na:na]
    at java.base/sun.security.x509.X509CertImpl.checkValidity(X509CertImpl.java:669) ~[na:na]
    at java.base/sun.security.x509.X509CertImpl.checkValidity(X509CertImpl.java:642) ~[na:na]
    at com.mysql.cj.protocol.ExportControlled$X509TrustManagerWrapper.checkServerTrusted(ExportControlled.java:383) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
    at java.base/sun.security.ssl.AbstractTrustManagerWrapper.checkServerTrusted(SSLContextImpl.java:1465) ~[na:na]
    at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:625) ~[na:na]
    ... 77 common frames omitted

我的application.properties文件

#==============================
#   MYSQL CONNECTION
#==============================
 spring.datasource.url=jdbc:mysql://ip:3306/dbName?user=userName
 spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
 spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
 spring.jpa.hibernate.ddl-auto=update
 spring.jpa.show-sql=true

我可能只是为了增加而改变了RDS中的参数组

  1. max_connect_errors = 100000;
  2. 最大错误计数= 10000;

可能是什么问题?

java mysql spring spring-boot rds
1个回答
0
投票
仅禁用与ssl的mysql连接。

#============================== # MYSQL CONNECTION #============================== spring.datasource.url=jdbc:mysql://ip:3306/dbName?user=userName&useSSL = false

© www.soinside.com 2019 - 2024. All rights reserved.