首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过SSL从Spring获取配置

通过SSL从Spring获取配置
EN

Stack Overflow用户
提问于 2016-10-14 13:14:29
回答 2查看 7.5K关注 0票数 3

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

我希望我的spring引导应用程序通过https与Config服务器通信。问题是,在从bootstrap.yml加载SSL配置之前,应用程序启动对Config的rest调用以获取配置,并在错误的情况下不幸失败:

代码语言:javascript
复制
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证书的信任存储库:

代码语言:javascript
复制
# 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

任何建议,我应该做什么来创建成功的SSL通信与Config Server?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-10-23 09:05:11

在JRE证书存储区导入CA证书后,问题得到了解决:

代码语言:javascript
复制
keytool -importcert -alias startssl -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -file ca.der
票数 2
EN

Stack Overflow用户

发布于 2016-10-14 13:33:16

看来它在找到cert文件方面有问题。我会尝试这样的方法。

代码语言:javascript
复制
   ssl:
      trust-store: file:/Certs/caCert/server.p12

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

代码语言:javascript
复制
   ssl:
      enabled: true
      key-store: file:/Certs/keystore
      key-password: keypwd
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40044128

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档