AWS DynamoDB加密无法解析HTTP响应内容

时间:2017-04-20 10:07:17

标签: amazon-web-services amazon-dynamodb

我使用aws-dynamodb-encryption-java的DirectKmsMaterialProvider来加密我要存储到dynamodb的数据,但是在调用 mapper.save(objectToSave) 时我收到以下错误:

 final EncryptionMaterialsProvider provider = new DirectKmsMaterialProvider(awskmsClient,
                    awsKMSAliasKey);
            mapper  = new DynamoDBMapper(dynamoDBClient, mapperConfig,
                    new AttributeEncryptor(provider));

错误:

com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException: com.amazonaws.AmazonServiceException: Unable to parse HTTP response content (Service: AWSKMS; Status Code: 302; Error Code: null; Request ID: null)
    at com.amazonaws.services.dynamodbv2.datamodeling.AttributeEncryptor.transform(AttributeEncryptor.java:67)[63:express-server:0.0.1.SNAPSHOT]
    at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.transformAttributes(DynamoDBMapper.java:2414)[63:express-server:0.0.1.SNAPSHOT]
    at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.transformAttributeUpdates(DynamoDBMapper.java:2446)[63:express-server:0.0.1.SNAPSHOT]
    at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.access$200(DynamoDBMapper.java:185)[63:express-server:0.0.1.SNAPSHOT]
    at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper$SaveObjectHandler.doUpdateItem(DynamoDBMapper.java:1080)[63:express-server:0.0.1.SNAPSHOT]
    at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper$2.executeLowLevelRequest(DynamoDBMapper.java:795)[63:express-server:0.0.1.SNAPSHOT]
    at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper$SaveObjectHandler.execute(DynamoDBMapper.java:974)[63:express-server:0.0.1.SNAPSHOT]
    at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.save(DynamoDBMapper.java:824)[63:express-server:0.0.1.SNAPSHOT]
    at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.save(DynamoDBMapper.java:669)[63:express-server:0.0.1.SNAPSHOT]

1 个答案:

答案 0 :(得分:0)

确保您的KMS端点正确无误 例如:

AWSKMSClient awsKMSClient = new AWSKMSClient(new InstanceProfileCredentialsProvider());
awsKMSClient.setEndpoint("kms.ap-southeast-1.amazonaws.com");

参考http://docs.aws.amazon.com/general/latest/gr/rande.html#kms_region