【问题标题】:Hashicorp Vault: "Code: 400. Errors" Error MessageHashicorp Vault:“代码:400。错误”错误消息
【发布时间】:2021-07-22 11:33:38
【问题描述】:

在使用带有机密 ID 文件的 Vault Agent 时,我收到以下错误消息:

$ ./vault agent --config auth_config.hcl
==> Vault server started! Log data will stream in below:

==> Vault agent configuration:

           Api Address 1: http://127.0.0.1:8300
                     Cgo: disabled
               Log Level: info
                 Version: Vault v1.3.0

2020-02-04T14:08:28.352-0800 [INFO]  auth.handler: starting auth handler
2020-02-04T14:08:28.352-0800 [INFO]  auth.handler: authenticating
2020-02-04T14:08:28.352-0800 [INFO]  sink.server: starting sink server
2020-02-04T14:08:28.352-0800 [INFO]  template.server: starting template server
2020-02-04T14:08:28.352-0800 [INFO]  template.server: no templates found
2020-02-04T14:08:28.352-0800 [INFO]  template.server: template server stopped
2020-02-04T14:08:28.354-0800 [ERROR] auth.handler: error authenticating: error="Error making API request.

URL: PUT http://127.0.0.1:8200/v1/auth/approle/login
Code: 400. Errors:

* invalid secret id" backoff=2.190384035

我执行的命令是:

vault agent --config auth_config.hcl

我的auth_config.hcl文件的内容是:

vault {
  address = "http://127.0.0.1:8200"
}

auto_auth {
  method "approle" {
    config {
      role_id_file_path = "./role_id"
      secret_id_file_path = "./secret_id"
      remove_secret_id_file_after_reading = false
    }
  }

}

cache {
  use_auto_auth_token = true
}

listener "tcp" {
  address = "127.0.0.1:8300"
  tls_disable = true
}

我的秘密 ID 是使用以下命令生成的:

vault write -f auth/approle/role/payments_service/secret-id -format=json | sed -E -n 's/.*"secret_id": "([^"]*).*/\1/p' > secret_id

为什么会出现这个错误?

【问题讨论】:

    标签: hashicorp-vault


    【解决方案1】:

    我发现发生这种情况的常见原因是因为秘密 ID 文件一开始就没有正确生成。例如,请参阅this Github thread。不幸的是,就我而言,该文件已生成。 auth_config.hcl 中引用的文件 secret_id 包含秘密 ID。

    在我的例子中,问题是在生成文件secret_id 后,我第二次执行了命令vault write -f auth/approle/role/payments_service/secret-id。这个新命令没有用新的秘密 ID 覆盖原始文件。这个新命令的结果是它重新生成了一个新的秘密 ID,这使之前写入 secret_id 文件的秘密 ID 无效。

    我的解决方案是重新运行将秘密 ID 写入文件 secret_id 的命令,然后立即运行 Vault Agent。问题解决了。

    【讨论】:

    【解决方案2】:

    我的情况是因为应用程序 (kes) 试图使用 http 而不是 https 来连接到 vault,而在 vault 和应用程序 (kes) 中都启用了 tls。更新后,该应用可以毫无问题地连接到保险库

    Error: failed to connect to Vault: Error making API request.
    
    URL: PUT http://vault.vault:8200/v1/auth/approle/login
    Code: 400. Raw Message:
    
    Client sent an HTTP request to an HTTPS server.
    Authenticating to Hashicorp Vault 'http://vault.vault:8200'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-24
      • 2015-03-08
      • 2019-05-03
      • 1970-01-01
      • 1970-01-01
      • 2021-02-07
      • 1970-01-01
      • 2021-07-16
      相关资源
      最近更新 更多