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

Authentication using certificate: curl working, but java driver is having issues #237

Open
patpatpat123 opened this issue Feb 8, 2021 · 1 comment

Comments

@patpatpat123
Copy link

Hello BetterCloud Team,

A big thanks for this cool project.

I am facing a small issue, hence reporting this as a bug.

I am trying to connect to our Vault back end, using certificate, not using tokens.

Hence, as a verification, we use a curl command first.

curl -vv -s -k -X $'PUT' --cacert ./mycert.crt --cert ./mycert.crt --key ./mykey.key https://x509.my-vault.com/v1/auth/cert/login | jq -r .auth.client_token

And this will yield the good token! Very happy.

Hence, just wanting to perform the same with this library:

public static void main( String[] args ) throws Exception {
      final VaultConfig config = new VaultConfig()
              .address("https://my-vault.com:443") //nox509 prefix
              .sslConfig(new SslConfig()
                      .clientPemUTF8("/mycert.crt")
                      .clientKeyPemUTF8("/mykey.key")
                      .build()).build();

      final Vault               vault   = new Vault(config, 1);
      System.out.println("checkpoint1" + vault.debug().health().getInitialized() + vault.debug().health().getRestResponse().getStatus() + new String(vault.debug().health().getRestResponse().getBody()));;

      final Map<String, Object> secrets = new HashMap<>();
      secrets.put("value", "hello world");

      final LogicalResponse writeResponse = vault.logical().write("cubbyhole/test", secrets);
      System.out.println("checkpoint2 " + writeResponse.getLeaseId() + writeResponse.getData() + writeResponse.getDataObject());

      final String value = vault.logical().read("cubbyhole/test").getData().get("value");

      System.out.println("checkpoint3 " + value);
  }

Sadly, this is not working (not able to write or read the secret.

Would it be possible those API have issues?

Please let me know if you believe I am the issue, i.e. I am not using things correctly.

Thank you!

@MiraHml
Copy link

MiraHml commented Jun 10, 2021

Any updates on this?

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

2 participants