More debug

main
Bob Mottram 2021-03-14 12:09:56 +00:00
parent 8c2b1e3018
commit 9ddda0b9e0
1 changed files with 14 additions and 3 deletions

View File

@ -354,14 +354,23 @@ def verifyPostHeaders(httpPrefix: str, publicKeyPem: str, headers: dict,
f'{signedHeader}: {headers[signedHeader]}') f'{signedHeader}: {headers[signedHeader]}')
else: else:
if '-' in signedHeader: if '-' in signedHeader:
# capitalise with dashes
# my-header becomes My-Header
headerParts = signedHeader.split('-') headerParts = signedHeader.split('-')
signedHeaderCap = '' signedHeaderCap = None
for part in headerParts: for part in headerParts:
if signedHeaderCap: if signedHeaderCap:
signedHeaderCap += '-' signedHeaderCap += '-' + part.capitalize()
signedHeaderCap += part.capitalize() else:
signedHeaderCap = part.capitalize()
else: else:
# header becomes Header
signedHeaderCap = signedHeader.capitalize() signedHeaderCap = signedHeader.capitalize()
if debug:
print('signedHeaderCap: ' + signedHeaderCap)
# if this is the date header then check it is recent
if signedHeaderCap == 'Date': if signedHeaderCap == 'Date':
if not _verifyRecentSignature(headers[signedHeaderCap]): if not _verifyRecentSignature(headers[signedHeaderCap]):
if debug: if debug:
@ -369,6 +378,8 @@ def verifyPostHeaders(httpPrefix: str, publicKeyPem: str, headers: dict,
'verifyPostHeaders date is not recent ' + 'verifyPostHeaders date is not recent ' +
headers[signedHeader]) headers[signedHeader])
return False return False
# add the capitalised header
if headers.get(signedHeaderCap): if headers.get(signedHeaderCap):
signedHeaderList.append( signedHeaderList.append(
f'{signedHeader}: {headers[signedHeaderCap]}') f'{signedHeader}: {headers[signedHeaderCap]}')