Hashicorp Vault:“代码:400。错误”错误消息

问题描述 投票:0回答:1

[将Vault Agent与机密ID文件一起使用时,我收到以下错误消息:

$ ./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个回答
0
投票

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

[对于我来说,问题在于生成文件secret_id后,我第二次执行了命令vault write -f auth/approle/role/payments_service/secret-id。此新命令未用新的机密ID覆盖原始文件。此新命令的结果是,它重新生成了一个新的秘密ID,从而使先前写入secret_id文件的秘密ID无效。

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

© www.soinside.com 2019 - 2024. All rights reserved.