Closed aditpshrimal closed 2 years ago
I tried using this code as well https://developers.google.com/tink/generate-encrypted-keyset. Even after using the same code as mentioned in the official documentation, it gives the same error.
Looks like there were conflicts between dependencies. After updating KMS, beam and tink to latest versions I was able to resolve the issue.
Hi team, PFB details of the task I plan to achieve.
Steps I have completed:
String masterKeyUri = "gcp-kms://projects/<project>/locations/global/keyRings/my-app-keyring/cryptoKeys/testKey"; KeysetHandle handle = KeysetHandle.generateNew(KmsAeadKeyManager.createKeyTemplate(masterKeyUri)); kekAead = handle.getPrimitive(Aead.class); KeysetHandle handle = KeysetHandle.generateNew(KeyTemplates.get("AES256_GCM")); handle.write(JsonKeysetWriter.withFile(new File("./secure_keys.json")), kekAead);
Issues:
File file = new File("./secure_keys.json"); String uri = "gcp-kms://projects/<project>/locations/global/keyRings/my-app-keyring/cryptoKeys/testKey"; KeysetHandle keysetHandle = KeysetHandle.read(JsonKeysetReader.withFile(file),new GcpKmsClient().getAead(uri));
I get the following errorException in thread "main" java.lang.NoSuchMethodError: com.google.gson.JsonParser.parseString(Ljava/lang/String;)Lcom/google/gson/JsonElement; at com.google.crypto.tink.JsonKeysetReader.readEncrypted(JsonKeysetReader.java:163) at com.google.crypto.tink.KeysetHandle.read(KeysetHandle.java:116) at org.example.analytics.KmsEncryption.initializeOnce(KmsEncryption.java:45) at org.example.analytics.JdbcToBigQuery.main(JdbcToBigQuery.java:18)
To Reproduce:
Please let me know if I am doing something wrong.