From cf69c4568b9b3e3cef2f2c49fa8a7034cb14534e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 16 Aug 2019 10:56:58 +0100 Subject: [PATCH] decode body digest --- httpsig.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpsig.py b/httpsig.py index 7f681e3f..6ca49c07 100644 --- a/httpsig.py +++ b/httpsig.py @@ -79,7 +79,7 @@ def createSignedHeader(privateKeyPem: str,nickname: str,domain: str,port: int, \ else: messageBodyJsonStr=json.dumps(messageBodyJson) bodyDigest = \ - base64.b64encode(SHA256.new(messageBodyJsonStr.encode()).digest()) + base64.b64encode(SHA256.new(messageBodyJsonStr.encode()).digest()).decode('utf-8') headers = {'(request-target)': f'post {path}','host': headerDomain,'date': dateStr,'digest': f'SHA-256={bodyDigest}','content-type': 'application/activity+json'} signatureHeader = signPostHeaders(privateKeyPem, nickname, domain, port, \ path, httpPrefix, None) @@ -121,7 +121,7 @@ def verifyPostHeaders(httpPrefix: str,publicKeyPem: str,headers: dict, \ f'(request-target): {method.lower()} {path}') elif signedHeader == 'digest': bodyDigest = \ - base64.b64encode(SHA256.new(messageBodyJsonStr.encode()).digest()).decode('utf-8') + base64.b64encode(SHA256.new(messageBodyJsonStr.encode()).digest()).decode('utf-8').decode('utf-8') signedHeaderList.append(f'digest: SHA-256={bodyDigest}') else: if headers.get(signedHeader):