From 7815126f65c840951e3d718b183b40825e5021c4 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 15 Aug 2019 18:09:17 +0100 Subject: [PATCH] Exception handling for http signature check --- httpsig.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/httpsig.py b/httpsig.py index 1564fee0..c50c2d90 100644 --- a/httpsig.py +++ b/httpsig.py @@ -117,8 +117,12 @@ def verifyPostHeaders(httpPrefix: str, publicKeyPem: str, headers: dict, \ base64.b64encode(SHA256.new(messageBodyJsonStr.encode()).digest()) signedHeaderList.append(f'digest: SHA-256={bodyDigest}') else: - signedHeaderList.append( - f'{signedHeader}: {headers[signedHeader]}') + try: + signedHeaderList.append( + f'{signedHeader}: {headers[signedHeader]}') + except Exception as e: + print('http signature check failure') + print(e) # Now we have our header data digest signedHeaderText = '\n'.join(signedHeaderList)