【问题标题】:Spring boot application not able to connect GCP Mysql instance using SSlSpring Boot 应用程序无法使用 SSl 连接 GCP Mysql 实例
【发布时间】:2018-08-08 03:16:46
【问题描述】:

我正在尝试在 Spring Boot 应用程序和 GCP MySQL 实例之间建立 SSL 连接。 为此已经生成并下载了“client-cert.pem”、“client-key.pem”和 来自 GCP 的“server-ca .pem”。 遵循以下步骤:

第 1 步:生成“my-cert.p12”文件

openssl pkcs12 -export -in client-cert.pem -inkey client-key.pem -out my-cert.p12 

第 2 步:导入“my-cert.p12”文件

keytool -importkeystore  -srckeystore D:\my-cert.p12 -destkeystore ./cacerts -srcstoretype PKCS12 -deststorepass changeit

setp 3:将“server-ca.pem”转换为“server-ca.der

openssl x509 -in server-ca.pem -inform pem -out server-ca.der -outform der

第 4 步:导入 'server-ca.der' keytool -importcert -alias gcp-mysql-ca -keystore ./cacerts -storepass changeit -file D:\server-ca.der

第五步:配置spring boot application.properties文件:

spring.datasource.url= jdbc:mysql://xxx.xxx.xxx.xxx:3306/xxx?useUnicode=true&characterEncoding=utf8&useSSL=true&requireSSL=true

当我运行 spring boot 应用程序时,出现以下异常:

原因:java.sql.SQLException: Access denied for user 'root'@'XXX.XXX.XXX.XX'(使用密码:YES)

谁能推荐一个安装 GCP MySQL SSL 证书并在 Spring Boot 应用程序中配置它的好方法?

【问题讨论】:

    标签: spring-boot


    【解决方案1】:

    您是否考虑过使用 Spring Cloud GCP SQL 集成? 您可以使用 Google OAuth2 凭据,其余的由 Spring Cloud GCP 处理。

    https://github.com/spring-cloud/spring-cloud-gcp

    https://docs.spring.io/spring-cloud-gcp/docs/1.0.0.M2/reference/htmlsingle/#_spring_jdbc

    【讨论】:

      猜你喜欢
      • 2020-08-18
      • 2017-07-10
      • 2021-04-22
      • 1970-01-01
      • 2020-06-27
      • 2020-02-22
      • 1970-01-01
      • 1970-01-01
      • 2017-07-08
      相关资源
      最近更新 更多