Java 通过SSL从Spring云配置获取配置
我正在使用SpringBoot构建微服务,其中配置是使用SpringCloudConfig分发的。配置应用程序已启用SSL 我希望我的spring启动应用程序通过https与配置服务器通信。问题是,在从bootstrap.yml加载SSL配置之前,应用程序启动了对Config Server的rest调用以获取配置,但由于错误而失败:Java 通过SSL从Spring云配置获取配置,java,ssl,spring-boot,microservices,spring-cloud-config,Java,Ssl,Spring Boot,Microservices,Spring Cloud Config,我正在使用SpringBoot构建微服务,其中配置是使用SpringCloudConfig分发的。配置应用程序已启用SSL 我希望我的spring启动应用程序通过https与配置服务器通信。问题是,在从bootstrap.yml加载SSL配置之前,应用程序启动了对Config Server的rest调用以获取配置,但由于错误而失败: java.lang.IllegalStateException: Could not locate PropertySource and the fail fast
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
#微服务属性
春天:
应用程序:
姓名:abcd
简介:
活动:开发、生产
云:
配置:
uri:https://:8888
快速失败:正确
密码:abc@123
用户名:user
服务器:
ssl:
信任存储:D:/Certs/caCert/server.p12
信任存储密码:keystore
密钥存储提供程序:PKCS12
有什么建议我应该如何创建与配置服务器的成功SSL通信吗?看起来在查找证书文件时出现了问题。我想试试这样的
ssl:
trust-store: file:/Certs/caCert/server.p12
更好的是,我会使用keytool将我的证书添加到密钥库文件中,这样我就可以像
ssl:
enabled: true
key-store: file:/Certs/keystore
key-password: keypwd
我在JRE证书存储中导入CA证书后,问题得到解决:
keytool -importcert -alias startssl -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -file ca.der