mysql jdbc ssl 连接不上,MySQL RDS和JDBC SSL连接错误:无法找到请求目标的有效证书路径...

I am trying to establish an SSL connection between JDBC and AWS RDS. Here I created a keystore using following commands:

# convert certificate into java understandable format

openssl x509 -outform der -in rds-combined-ca-bundle.pem -out rds-combined-ca-bundle.der

# importing the certificate to keystore

sudo keytool -keystore keystore -alias rds_postgresql -import -file rds-combined-ca-bundle.der

And then set the value of keystore and keystore password directly into the application

System.setProperty("javax.net.ssl.keyStore", "/path/of/the/keystore");

System.setProperty("javax.net.ssl.keyStorePassword", "******");

But, after adding all these settings, I am getting following error

Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141) ~[?:1.8.0_131]

at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126) ~[?:1.8.0_131]

at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280) ~[?:1.8.0_131]

at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382) ~[?:1.8.0_131]

at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292) ~[?:1.8.0_131]

at sun.security.validator.Validator.validate(Validator.java:260) ~[?:1.8.0_131]

What is wrong here?

I followed this tutorial to setup SSL:

解决方案

Since rds-combined-ca-bundle.pem contains a bunch of certificates, if we split them and create .pem files for all certificates and import them to keystore separately, it will work.

The problem is caused because of importing the entire rds certificate bundle to keystore.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值