【问题标题】:Fetch Configuration from Spring Cloud Config over SSL通过 SSL 从 Spring Cloud Config 获取配置
【发布时间】:2017-02-23 22:37:41
【问题描述】:

我正在使用 Spring Boot 构建微服务,其中使用 Spring Cloud Config 分发配置。 Config 应用程序已启用 SSL。

我希望我的 Spring Boot 应用程序通过 https 与配置服务器通信。问题是,在从 bootstrap.yml 加载 SSL 配置之前,应用程序向 Config Server 发起了一个 rest 调用以获取配置,并因错误而惨遭失败:

java.lang.IllegalStateException: Could not locate PropertySource and the fail fast property is set, failing
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://host:8888/abcd/development,production": sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: 

我在 bootstrap.yml 中配置了一个带有 CA 证书的信任库:

# MicroServices Properties
spring:
  application:
     name: abcd
  profiles:
    active: development,production
  cloud:
    config:
      uri: https://<host>:8888 
      fail-fast: true
      password: abc@123
      username: user
server:
  ssl:
    trust-store: D:/Certs/caCert/server.p12
    trust-store-password: keystore
    key-store-provider: PKCS12

我应该怎么做才能与 Config Server 建立成功的 SSL 通信?

【问题讨论】:

    标签: java ssl spring-boot microservices spring-cloud-config


    【解决方案1】:

    我在 JRE 证书存储中导入 CA 证书后问题解决了:

    keytool -importcert -alias startssl -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -file ca.der
    

    【讨论】:

      【解决方案2】:

      看起来在查找证书文件时有问题。我会尝试这样的。

         ssl:
            trust-store: file:/Certs/caCert/server.p12
      

      更好的是,我会使用 keytool 将我的证书添加到密钥库文件中,这样我就可以像访问我的密钥库文件一样

         ssl:
            enabled: true
            key-store: file:/Certs/keystore
            key-password: keypwd
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-03-22
        • 1970-01-01
        • 1970-01-01
        • 2019-03-20
        • 2020-06-03
        • 2021-01-09
        • 2018-05-30
        相关资源
        最近更新 更多