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

企业家

将 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

为什么会发生此错误?

企业家

我发现发生这种情况的通常原因是最初没有正确生成机密 ID 文件。例如,请参阅此 Github 线程不幸的是,就我而言,该文件已生成。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。问题解决了。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章