3

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

我希望我的 Spring Boot 应用程序通过 https 与 Config 服务器通信。问题是,在从 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 通信?

4

2 回答 2

2

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

keytool -importcert -alias startssl -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -file ca.der
于 2016-10-23T09:05:11.010 回答
0

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

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

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

   ssl:
      enabled: true
      key-store: file:/Certs/keystore
      key-password: keypwd
于 2016-10-14T13:33:16.937 回答