Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use Logical read API #252

Open
vivshrivastava opened this issue Sep 17, 2022 · 0 comments
Open

Unable to use Logical read API #252

vivshrivastava opened this issue Sep 17, 2022 · 0 comments

Comments

@vivshrivastava
Copy link

vivshrivastava commented Sep 17, 2022

I am using Logical API and even though the REST call works, which is supposedly executed by the Logical API, the API does not work.

---- This does not work ----

final VaultConfig authConfig = new VaultConfig().address(vaultAddress).sslConfig(new SslConfig().verify(false)).nameSpace("mynamespace").build();
    final Vault authVault = new Vault(authConfig);
    final AuthResponse authResp = authVault.auth().loginByAppRole("venafi-pki","xxxxxx", "xxxxxxxx");
    final String token = authResp.getAuthClientToken();
    VaultConfig config = new VaultConfig().address(vaultAddress)
                .token(token)
                .sslConfig(new SslConfig().verify(false))
                // .prefixPath("venafi-pki/cert/mycert")
                .build();
 Vault vault = new Vault(config);

  Map<String,String> password = vault.logical()
          .read("venafi-pki/cert/mycert")
          .getData();
  System.out.println("Vault password is " + password);
 
-- This produces empty result --

----This works -----

 final RestResponse restResponse = new Rest()//NOPMD
                      .url(config.getAddress() + "/v1/" + "venafi-pki/cert/mycert")
                      .header("X-Vault-Token", config.getToken())
                      .header("X-Vault-Namespace", "mynamespace")
                      .connectTimeoutSeconds(config.getOpenTimeout())
                      .readTimeoutSeconds(config.getReadTimeout())
                      .sslVerification(config.getSslConfig().isVerify())
                      .sslContext(config.getSslConfig().getSslContext())
                      .get();

 String vaultResponse = new String(restResponse.getBody(), StandardCharsets.UTF_8);
 This produces the required output. 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant