我正在使用 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 通信?