Add debug logging for digest failure, reset body stream when reading alt key

This commit is contained in:
jvyden 2022-02-16 14:30:09 -05:00
commit 489da20395
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278

View file

@ -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();