BetterCloud / vault-java-driver

Zero-dependency Java client for HashiCorp's Vault
https://bettercloud.github.io/vault-java-driver/
334 stars 224 forks source link

Using Transit service doesn't work for anything other than engine Version 1 #234

Open agupta-hw opened 3 years ago

agupta-hw commented 3 years ago
Hi, I am trying to use this Vault Client to do encrypt/decrypt with Vault and having issues. 

Sample code below, when using
final Vault vault = new Vault(config) does not work. Nothing is wrong in config as the health check passes and just specifying the version explicitly to 1 works fine. Is this intentional? 
 try {
            final Vault vault = new Vault(config, 1);
            String base64EncodedString = Base64.getEncoder().encodeToString(plainText.getBytes(StandardCharsets.UTF_8));

            LogicalResponse response =
                    vault.logical().write("transit/encrypt/" + keyName, Collections.singletonMap("plaintext", base64EncodedString));
            //TODO For Initial Debugging/Dev
            logger.info("CipherText: {}", response.getDataObject().get("ciphertext"));
        } catch (VaultException e) {
            throw new RuntimeException("Could not encrypt for key " + key);
        }