0

似乎无法通过此错误。hashcorp vault 正在我的 k3s 环境中运行。我可以很好地进入保险库 UI。我还可以使用以下命令 curl Vault [POST, GET]:

curl --location --request POST 'http://192.168.8.110:31476/v1/niv/data/foo' 
--header 'X-Vault-Token: myroot' 
--header 'Content-Type: application/json' 
--data-raw '{
  "options": {
    "cas": 0
  },
  "data": {
    "foo": "bar",
    "zip": "zap"
  },
  "versions": [4]
}'
curl --location --request GET 'http://192.168.8.110:31476/v1/niv/data/foo?version=1' --header 'X-Vault-Token: myroot'

上面的卷曲工作正常。

当我尝试使用 .net 5 运行以下代码时,即使路径正确,我也会收到以下异常

using VaultSharp;
using VaultSharp.V1.AuthMethods;
using VaultSharp.V1.AuthMethods.Token;
IAuthMethodInfo authMethod = new TokenAuthMethodInfo("myroot");
var vaultClientSettings = new VaultClientSettings("http://192.168.8.110:31476/", authMethod);
IVaultClient vaultClient = new VaultClient(vaultClientSettings);
var secret = vaultClient.V1.Secrets.KeyValue.V2.ReadSecretAsync("niv/data/foo").Result.Data;

我得到以下异常:

VaultApiException: {"errors":["no handler for route 'kv-v2/data/niv/data/foo'"]}

4

1 回答 1

0

路径错误,下面的路径工作正常

var vaultSecrets = vaultClient.V1.Secrets.KeyValue.V2.ReadSecretAsync("/settings", 2, "niv").Result.Data.Data["name"];
于 2021-11-03T09:15:49.217 回答