Секретный ключ в конечном итоге окажется в хранилище ключей. , и 'receievedHmac' будет взят из заголовка сообщения.
Остальная часть этого, похоже, работает до тех пор, пока не достигнет оператора if, который сравнивает локально вычисленный HMAC с полученным ХМАС. (всего две строки)
Не понимаю, почему в операторе if может возникнуть ошибка.
Код: Выделить всё
// Add the required libraries
#r "Newtonsoft.Json"
#r "Microsoft.Azure.Workflows.Scripting"
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Microsoft.Extensions.Logging;
using Microsoft.Azure.Workflows.Scripting;
using Newtonsoft.Json.Linq;
using System;
using System.Security.Cryptography;
using System.Text;
///
/// Executes the inline csharp code.
///
///
The workflow context.
/// This is the entry-point to your code. The function signature should remain unchanged.
public static async Task Run(WorkflowContext context, ILogger log)
{
var triggerOutputs = (await context.GetTriggerResults().ConfigureAwait(false)).Outputs;
////the following dereferences the 'name' property from trigger payload.
var name = triggerOutputs?["body"]?["name"]?.ToString();
string compare = string.Empty;
////Set the local HMAC key from the Azure Key Vault.
string secretKey = "HMAC-GG-TEST"; //Temporary for testing only...
//var secretKey = await client.GetSecretAsync(secretName);
////Set the whole JSON body text from the trigger.
var origonalMessage = triggerOutputs["body"].ToString();
////Set the remote HMAC encripted text from the Azure header.
string receievedHmac = "af9d5fe5216e4a3c731cc864ddc0dba66ae22b68605678fd2a3c381dc5c72025"; //
Подробнее здесь: [url]https://stackoverflow.com/questions/79272756/how-do-you-compare-local-and-remote-hmac-strings-in-an-azure-workflow-csharp-sc[/url]