简体   繁体   English

如何使用Java配置与Azure托管的MySQL的SSL连接?

[英]How to configure SSL connection to MySQL hosted on Azure with Java?

On Azure I have found 4 certificates: 在Azure上,我发现了4个证书:

ClearDB CA Certificate
Client Certificate
Client Private Key
Client Certificate Bundle(for Windows only)

I have created trustStore with ClearDB CA like it was told here How to connect to a remote MySQL database via SSL using Play Framework? 我已经用ClearDB CA创建了trustStore ,就像这里所说的那样。 如何使用Play Framework通过SSL连接到远程MySQL数据库?

keytool -import -alias mysqlServerCACert -file cleardb.pem -keystore truststore.jks

Set Systems properties like this: 设置系统属性如下:

System.setProperty("javax.net.ssl.trustStore", "path/truststore.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "password");

Added parameters to jdbc url 向jdbc url添加参数

?useSSL=true&requireSSL=true&verifyServerCertificate=true

But I still get Exception 但是我仍然得到异常

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 javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:找不到指向所请求目标的有效证书路径

I'm really confused. 我真的很困惑 Which certificate I should use. 我应该使用哪个证书。 What for are other certificates? 什么是其他证书? Will appreciate any help. 将不胜感激。

@OlegKuts, according to the ClearDB FAQ about enforce client SSL (or x.509) authentication as below, I think you should use the ClearDB CA certificate if it's got from ClearDB. @OlegKuts,根据如下有关执行客户端SSL(或x.509)身份验证的ClearDB 常见问题解答 ,我认为您应该使用ClearDB CA证书(如果它是从ClearDB获得的)。

I need additional security options for my ClearDB cluster. 我的ClearDB集群需要其他安全选项。 How can I enforce client SSL (or x.509) authentication? 如何执行客户端SSL(或x.509)身份验证?

We operate our own CA, and we'll be happy to generate x.509 user authentication certificates for your account. 我们运营自己的CA,很乐意为您的帐户生成x.509用户身份验证证书。 Please send us a support request (login required) to get x.509 certificates. 向我们发送支持请求 (需要登录)以获取x.509证书。

Meanwhile, according to the ClearDB help & support page (its link for Java is not available, but please see the rear MySQL 5.5 link), you need to follow the MySQL connector document 5.5 Connecting Securely Using SSL to try again. 同时,根据ClearDB帮助和支持页面 (它的Java链接不可用,但请参阅后面的MySQL 5.5链接),您需要阅读MySQL连接器文档5.5“使用SSL安全连接”才能重试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM