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

标签 java mysql amazon-web-services amazon-rds

我正在尝试从 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/

相关文章:

java - 生成API文档的流程

php - 显示数据库中的特色项目

php - 从 WordPress 中的自定义表返回变量(从 URL 检索后)

java - AWS Elastic BeansTalk Nginx 超时 504 错误网关 - Java Servlet AsyncContext

typescript - 是否可以从 IAM 角色运行 cdk 命令?

amazon-web-services - 循环中的 AWS BatchGetItem 与 GetItem

java - 子类在 Java 中使用哪些数据成员?

java - 如何将 Mock 设置为具有默认行为并可以在某些测试中覆盖它

mysql - 更改Mysql中表的存储引擎

java - "getDeclaredXyz"在Java反射包中代表什么