Closed
Description
Wondering if there is an issue with getting the region when the profile is federated. I am in a federated account using a role that has kms:*
, and I get this when decrypting:
com.amazonaws.encryptionsdk.exception.CannotUnwrapDataKeyException: Unable to decrypt any data keys
This is not an issue with using aliases. This works perfect in another account where I am not federated, using an IAM User with full admin permissions. Is there something else needed here?
@Override
public void decryptFile(
final String encryptedFilename,
final String decryptedFilename) {
final KmsMasterKeyProvider provider
= new KmsMasterKeyProvider(
new DefaultAWSCredentialsProviderChain());
final AwsCrypto awsCrypto
= new AwsCrypto();
try (final FileInputStream fileInputStream
= new FileInputStream(
encryptedFilename);
final FileOutputStream fileOutputStream
= new FileOutputStream(
decryptedFilename);
final CryptoInputStream<?> decryptingStream
= awsCrypto
.createDecryptingStream(
provider,
fileInputStream)) {
IOUtils.copy(
decryptingStream,
fileOutputStream);
} catch (IOException exception) {
throw new DecryptionException(exception);
}
}