0

I am using hashicorp's vault and trying to add secrets in that using java. I am able to add secrets in the vault but it always replaces the older secrets.

public static void main(String[] args) throws VaultException {
            final Vault vault = new Vault(new VaultConfig()
                    .address("https://vault")
                    .token("s.")
                    .build());
    
    
            final Map<String, Object> secrets = new HashMap<>();
            secrets.put("kk1", "value1234");
            secrets.put("kk", "value");
            LogicalResponse write = vault.logical().write("v1/kartike", secrets);
        }

I just wanted to confirm if it is a bug at hashicorp api or there is something I am missing. I am stuck at it.

Kampassi
  • 123
  • 7
  • If you want to add a secret, then you need to either specify a new path, or specify the old secrets in addition to the new secrets at the same path. Could you please expand on how you are adding the secrets? Your code above would not replace any older secrets unless you invoked it multiple times. – Matthew Schuchard Oct 13 '21 at 14:15
  • i have my secrets as {"k": "k"} vault. when i execute the above code, my secret gets replaced with the kk1 and kk. – Kampassi Oct 13 '21 at 15:09
  • This code must be executing with a policy that authorizes the `put` to the path `/path/to/v1/kartike/` with a `create`. Does it also have `read` authorization? – Matthew Schuchard Oct 13 '21 at 17:27

0 Answers0