与MySQL RDS在Hibernate中启用SSL [英] Enabling SSL with MySQL RDS in Hibernate

查看:655
本文介绍了与MySQL RDS在Hibernate中启用SSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从休眠安全地连接到RDS实例。在我hibernate.cfg文件相关属性看起来是这样的。

I am trying to connect securely to RDS instance from Hibernate. Relevant properties in my hibernate.cfg file looks like this.

<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>

不过,我得到以下异常。

But I am getting following exception.

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实例配置什么呢?

Do I need to configure something on my RDS instance as well?

谢谢

推荐答案

我能解决这个问题,但不知道病根呢。

I was able to fix this but don't know root cause yet.

不知怎的,分别加入这些连接属性是行不通的,但是当我加入他们作为参数连接的URL,它的工作。

Somehow adding these connection properties separately was not working but when I added them as parameters in connection URL, it worked.

 jdbc:mysql://<endpoint>/<db>?autoReconnect=true&useUniCode=true&characterEncoding=UTF-8&useSSL=true&verifyServerCertificate=false&requireSSL=true

这篇关于与MySQL RDS在Hibernate中启用SSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆