Skip to content

Unable to use Logical read API #252

@vivshrivastava

Description

@vivshrivastava

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. 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions