gpt4 book ai didi

java - 在 Hibernate 中使用 MySQL RDS 启用 SSL

转载 作者:行者123 更新时间:2023-11-30 23:32:46 25 4
gpt4 key购买 nike

我正在尝试从 Hibernate 安全地连接到 RDS 实例。我的 hibernate.cfg 文件中的相关属性如下所示。

<property name="connection.url">
jdbc:mysql://<endpoint>/<db>?autoReconnect=true&amp;useUniCode=true&amp;characterEncoding=UTF-8&amp;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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com