I am not able to create secret using keywhiz api.
hshyamh4 opened this issue · comments
I used below code to create secret,
public static void testCreateNewSecrete() throws IOException{
KeywhizClient keywhizClient = keywhizClient();
keywhizClient.login("keywhizAdmin", "adminPass".toCharArray());
String str = FileUtils.readFileToString(new File("path/to/somefile/location/DefaultBundle.jceks"),"UTF-8");
ImmutableMap<String,String> myMap = ImmutableMap.<String, String>builder().put("client", "client").put("group", "Security").build();
SecretDetailResponse createSecret = keywhizClient.createSecret("key_store","key store", str, true, myMap);
System.out.println(createSecret);
}
Then i getting below exception,
Exception in thread "main" keywhiz.client.KeywhizClient$ValidationException: Malformed request semantics from client (422)
at keywhiz.client.KeywhizClient.throwOnCommonError(KeywhizClient.java:263)
at keywhiz.client.KeywhizClient.httpPost(KeywhizClient.java:290)
at keywhiz.client.KeywhizClient.createSecret(KeywhizClient.java:148)
at com.cybermoney.keywhiz.Application.testCreateNewSecrete(Application.java:45)
at com.cybermoney.keywhiz.Application.main(Application.java:37)
How to how to convert somesecretFile.jceks to string and make above code working ?
If i do not use file content then it is working.
You're getting an error for malformed request because the content field must be base64. It's annotated on the class.
I have an unrelated PR out (#116), that changes KeywhizClient to take a byte[]
and does the base64'ing there.