From 489da203959255f09f48e4d4b3a96016840d786f Mon Sep 17 00:00:00 2001 From: jvyden Date: Wed, 16 Feb 2022 14:30:09 -0500 Subject: [PATCH] Add debug logging for digest failure, reset body stream when reading alt key --- ProjectLighthouse/Startup/Startup.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ProjectLighthouse/Startup/Startup.cs b/ProjectLighthouse/Startup/Startup.cs index ec293d74..5cc33fe0 100644 --- a/ProjectLighthouse/Startup/Startup.cs +++ b/ProjectLighthouse/Startup/Startup.cs @@ -183,9 +183,18 @@ public class Startup // If we got here, the normal ServerDigestKey failed to validate. Lets try again with the alternate digest key. usedAlternateDigestKey = true; + // Reset the body stream + body.Position = 0; + clientRequestDigest = await HashHelper.ComputeDigest(digestPath, authCookie, body, ServerSettings.Instance.AlternateDigestKey); if (clientRequestDigest != sentDigest) { + #if DEBUG + Console.WriteLine("Digest failed"); + Console.WriteLine("digestKey: " + ServerSettings.Instance.ServerDigestKey); + Console.WriteLine("altDigestKey: " + ServerSettings.Instance.AlternateDigestKey); + Console.WriteLine("computed digest: " + clientRequestDigest); + #endif // We still failed to validate. Abort the request. context.Response.StatusCode = 403; context.Abort();