From 9ddda0b9e04ce752db37ee31aa255de6919ea35a Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 14 Mar 2021 12:09:56 +0000 Subject: [PATCH] More debug --- httpsig.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/httpsig.py b/httpsig.py index 192658648..077e95a10 100644 --- a/httpsig.py +++ b/httpsig.py @@ -354,14 +354,23 @@ def verifyPostHeaders(httpPrefix: str, publicKeyPem: str, headers: dict, f'{signedHeader}: {headers[signedHeader]}') else: if '-' in signedHeader: + # capitalise with dashes + # my-header becomes My-Header headerParts = signedHeader.split('-') - signedHeaderCap = '' + signedHeaderCap = None for part in headerParts: if signedHeaderCap: - signedHeaderCap += '-' - signedHeaderCap += part.capitalize() + signedHeaderCap += '-' + part.capitalize() + else: + signedHeaderCap = part.capitalize() else: + # header becomes Header signedHeaderCap = signedHeader.capitalize() + + if debug: + print('signedHeaderCap: ' + signedHeaderCap) + + # if this is the date header then check it is recent if signedHeaderCap == 'Date': if not _verifyRecentSignature(headers[signedHeaderCap]): if debug: @@ -369,6 +378,8 @@ def verifyPostHeaders(httpPrefix: str, publicKeyPem: str, headers: dict, 'verifyPostHeaders date is not recent ' + headers[signedHeader]) return False + + # add the capitalised header if headers.get(signedHeaderCap): signedHeaderList.append( f'{signedHeader}: {headers[signedHeaderCap]}')