in src/Internal/SetupDecryptionHandlerV1.cs [48:84]
private static string GetKmsKeyIdFromMetadata(MetadataCollection metadata)
{
var materialDescriptionJsonString = metadata[EncryptionUtils.XAmzMatDesc];
if (materialDescriptionJsonString == null)
{
throw new InvalidDataException( $"{KMSKeyIDMetadataMessage} The key '{EncryptionUtils.XAmzMatDesc}' is missing.");
}
else
{
JsonData materialDescriptionJsonData;
try
{
materialDescriptionJsonData = JsonMapper.ToObject(materialDescriptionJsonString);
}
catch (JsonException e)
{
throw new InvalidDataException($"{KMSKeyIDMetadataMessage} The key '{EncryptionUtils.XAmzMatDesc}' does not contain valid JSON.", e);
}
JsonData kmsKeyIDJsonData;
try
{
kmsKeyIDJsonData = materialDescriptionJsonData[EncryptionUtils.KMSCmkIDKey];
}
catch (JsonException e)
{
throw new InvalidDataException($"{KMSKeyIDMetadataMessage} The key '{EncryptionUtils.KMSCmkIDKey}' is does not contain valid JSON.", e);
}
if (kmsKeyIDJsonData == null)
{
throw new InvalidDataException($"{KMSKeyIDMetadataMessage} The key '{kmsKeyIDJsonData}' is missing from the material description.");
}
return kmsKeyIDJsonData.ToString();
}
}