我在cubbyhole
名为 的默认秘密引擎中创建了一个秘密secret1
。
现在我想阅读这个秘密,它在 Vault Online CLI 中运行良好:
vault read cubbyhole/secret1
但是使用以下代码:
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
ReadSecret().Wait();
}
public static async Task ReadSecret()
{
IAuthMethodInfo authMethod = new TokenAuthMethodInfo("My Token");
var vaultClientSettings = new VaultClientSettings("My Url", authMethod);
IVaultClient vaultClient = new VaultClient(vaultClientSettings);
Secret<SecretData> kv2Secret = await vaultClient.V1.Secrets.KeyValue.V2.ReadSecretAsync(path: "secret1");
Console.WriteLine($"Secret data : {kv2Secret.Data}");
}
我得到一个Permission Exception。
我试图将代码更改为:
Secret<SecretData> kv2Secret = await vaultClient.V1.Secrets.KeyValue.V2.ReadSecretAsync(path: "secret1", mountPoint: "cubbyhole");
我得到了错误:
System.AggregateException : 'One or more errors occurred. ({"errors":[]})'
我怎样才能读懂我的秘密?