spring-boot - Hashicorp Vault 错误 : Error checking seal status

标签 spring-boot ssl ssl-certificate keystore hashicorp-vault

我正在使用 Hashicorp vault 生成自签名证书,并使用以下链接成功生成 CA 证书、颁发 ca、ca-chain 和私钥:
Policies , Build Your Certificate .我还可以导入结果 .pem将证书、颁发Ca、caChain 和privateKey 文件组合成一个Java keystore 成功与keytool获取 .jks .
因此,我使用此命令成功启动 Vault vault server -config=config.hcl输出如下:

==> Vault server configuration:

             Api Address: https://test.sammy.com:8200
                     Cgo: disabled
         Cluster Address: https://test.sammy.com:8201
              Listener 1: tcp (addr: "127.0.0.1:9000", cluster address: "127.0.0.1:9001", max_request_duration: "1m30s", max_request_size: "33554432", tls: "disabled")
              Listener 2: tcp (addr: "127.0.0.1:8200", cluster address: "127.0.0.1:8201", max_request_duration: "1m30s", max_request_size: "33554432", tls: "enabled")
               Log Level: info
                   Mlock: supported: true, enabled: true
           Recovery Mode: false
                 Storage: inmem
                 Version: Vault v1.4.2

==> Vault server started! Log data will stream in below:

2020-06-28T23:37:01.489+0100 [INFO]  proxy environment: http_proxy= https_proxy= no_proxy=
使用配置文件config.hcl (如下所示)来自此 StackOverflow question :
backend "inmem" {}

listener "tcp" {
  address = "127.0.0.1:9000"
  tls_disable = 1
}

listener "tcp" {
  address = "127.0.0.1:8200"
  tls_disable = 0
  tls_cert_file = "/Vault/pki_ca_cert_chain.pem"
  tls_key_file = "Vault/vault.key.pem"
}

# Advertise the non-loopback interface
api_addr = "https://test.sammy.com:8200"
cluster_addr = "https://test.sammy.com:8201"
我使用这个命令来暴露服务器地址:export VAULT_ADDR='https://test.sammy.com:8200' .
我现在遇到的问题是,当我运行此命令查看服务器状态时 vault status ,我收到以下错误:
Error checking seal status: Get https://test.sammy.com:8200/v1/sys/seal-status: dial tcp 45.33.2.79:8200: connect: no route to host
我的 Spring Boot 应用程序选择了 truststore 文件,但在运行时抛出了这个异常:I/O exception (java.net.NoRouteToHostException) caught when processing request to {s}->https://test.sammy.com:8200: No route to host (Host unreachable)或者简单地说,Caused by: java.net.NoRouteToHostException: No route to host (Host unreachable) .我的 bootstrap.yml 看起来像这样
spring:
  application:
    name: hashicorp-spring-app
  cloud:
    vault:
      enabled: true
      host: test.sammy.com
      port: 8200
      scheme: https
      authentication: cert
      ssl:
        trust-store: classpath:vault-truststore.jks
        trust-store-password: somethingsecret
当我尝试使用以下命令初始化 Vault 时出现不同的错误:vault operator init
Error initializing: Put https://test.sammy.com:8200/v1/sys/init: dial tcp 45.79.19.196:8200: i/o timeout
我试过这个link修复它,但我仍然收到上面的 I/O 超时错误。我很确定我错过了一些可能很简单的事情,并且已经在互联网上寻找一个简单的解决方案,但似乎找不到任何解决方案,所以请,任何帮助将不胜感激!!!

最佳答案

由于以下代码,您的 Vault 实例仅监听环回地址:

listener "tcp" {
  address = "127.0.0.1:9000"
  tls_disable = 1
}
所以你有2个选择:
  • 在本地运行您的客户端并设置 VAULT_ADDR=127.0.0.1:9000在您的环境变量中
  • 将您的配置更改为 address = 0.0.0.0:9000并使用标准网络访问监听所有接口(interface)的 Vault。

  • 至于api_addr ,它用于告诉 Vault 如何向其客户宣传自己。它不用于首先到达它。因此,放在那里的值(value)取决于您的客户如何访问 Vault。例如,该地址将发送给使用 X-Vault-No-Request-Forwarding: 1 选择退出 Vault 请求转发的客户。 .cluster_addr参数不同:它仅由 Vault 使用,而不是您的客户使用。 Vault 使用它与集成存储达成共识,或者如果您使用 Vault Enterprise,则与其他集群进行复制。

    关于spring-boot - Hashicorp Vault 错误 : Error checking seal status,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62629294/

    相关文章:

    spring - Spring Boot 2.0.2.RELEASE 的模型验证异常

    java - 有没有办法用 spring boot 自动配置注册一个存储库基类?

    macos - 在 macOS 中将自签名证书添加为受信任的证书无法正常工作

    google-app-engine - 为 Google App Engine 上传通配符 SSL 证书会给出 "The SSL certificate references subdomain outside of managed domain."

    spring - 找不到mainClassName,不需要

    java - Spring "The request was rejected because the URL was not normalized."如何判断使用了什么 url?

    authentication - 如何设置 IIS 来验证客户端证书并将其作为 http header 传递到后端?

    tomcat - 禁用客户端证书提示

    ssl - 如果必须使用 Active Directory 进行身份验证,是否应该将 LDAPS 证书导入每台客户端计算机?

    iphone - 针对 MITM 验证 SSL 证书