似乎无法通过此错误。Hashicorp vault在我的k3s环境上运行。我可以去保险库,很好。我还可以使用以下方法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'
上面的curl可以正常工作。
当我尝试使用。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: {"error "; [" none handler for route 'kv-v2/data/niv/data/foo'"]}
路径错误,下面的路径正常
var vaultSecrets = vaultClient.V1.Secrets.KeyValue.V2.ReadSecretAsync("/settings", 2, "niv").Result.Data.Data["name"];