我正在尝试从 Hibernate 安全地连接到 RDS 实例。我的 hibernate.cfg 文件中的相关属性如下所示。
<property name="connection.url">
jdbc:mysql://<endpoint>/<db>?autoReconnect=true&useUniCode=true&characterEncoding=UTF-8&useSSL=true
</property>
<property name="dialect"> org.hibernate.dialect.MySQLDialect </property>
<property name="connection.verifyServerCertificate">false</property>
<property name="connection.requireSSL">true</property>
但是我遇到了以下异常。
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
我是否还需要在我的 RDS 实例上配置一些东西?
谢谢,
最佳答案
我能够解决这个问题,但还不知道根本原因。
以某种方式单独添加这些连接属性不起作用,但是当我将它们作为连接 URL 中的参数添加时,它起作用了。
jdbc:mysql://<endpoint>/<db>?autoReconnect=true&useUniCode=true&characterEncoding=UTF-8&useSSL=true&verifyServerCertificate=false&requireSSL=true
关于java - 在 Hibernate 中使用 MySQL RDS 启用 SSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9729739/