当使用 MySQL RDS 作为后台存储时,如何解决 WSO2IS-5.7 上的 unknown_ca 错误?

当使用 MySQL RDS 作为后台存储时,如何解决 WSO2IS-5.7 上的 unknown_ca 错误?

我尝试通过mysql-connector-java-5.1.45-bin.jar jdbc url使用 aws RDS 作为数据源在 AWS 上安装一个实例

jdbc:mysql://< instance>.< zone>.rds.amazonaws.com:3306/carbon_db

我有一个例外

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failurecom.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

    The last packet successfully received from the server was 7 milliseconds ago.  The last packet sent successfully to the server was 7 milliseconds ago.
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
    .
    .
    .
    Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: unknown_ca

我试过跑

keytool -importcert -keystore <keystore> -storepass <pass> -noprompt -file rds-combined-ca-bundle.pem

cacerts.jksJVM 中和client-trustore.jksWSO2 存储库中没有任何变化

答案1

如果您收到 SQLException:连接被拒绝或连接超时或 MySQL 特定的 CommunicationsException:通信链接失败,则意味着数据库根本无法访问。这可能由以下一个或多个原因造成:

IP address or hostname in JDBC URL is wrong.
Hostname in JDBC URL is not recognized by local DNS server.
Port number is missing or wrong in JDBC URL.
DB server is down.
DB server doesn't accept TCP/IP connections.
DB server has run out of connections.
Something in between Java and DB is blocking connections, e.g. a firewall or proxy. 

要解决其中一个问题,请遵循以下建议:

Verify and test them with ping.
Refresh DNS or use IP address in JDBC URL instead.
Verify it based on my.cnf of MySQL DB.
Start the DB.
Verify if mysqld is started without the --skip-networking option.
Restart the DB and fix your code accordingly that it closes connections in finally.
Disable firewall and/or configure firewall/proxy to allow/forward the port. 

相关内容