master
Bob Mottram 2019-08-16 10:00:10 +01:00
parent e86a01a9c4
commit d538e901a2
1 changed files with 2 additions and 2 deletions

View File

@ -33,7 +33,7 @@ def signPostHeaders(privateKeyPem: str, nickname: str, domain: str, \
headers = {'(request-target)': f'post {path}','host': domain,'date': dateStr,'content-type': 'application/json'} headers = {'(request-target)': f'post {path}','host': domain,'date': dateStr,'content-type': 'application/json'}
else: else:
bodyDigest = \ bodyDigest = \
base64.b64encode(SHA256.new(messageBodyJson.encode()).digest()) base64.b64encode(SHA256.new(messageBodyJson.encode()).digest()).decode('utf-8')
headers = {'(request-target)': f'post {path}','host': domain,'date': dateStr,'digest': f'SHA-256={bodyDigest}','content-type': 'application/json'} headers = {'(request-target)': f'post {path}','host': domain,'date': dateStr,'digest': f'SHA-256={bodyDigest}','content-type': 'application/json'}
privateKeyPem = RSA.import_key(privateKeyPem) privateKeyPem = RSA.import_key(privateKeyPem)
#headers.update({ #headers.update({
@ -121,7 +121,7 @@ def verifyPostHeaders(httpPrefix: str,publicKeyPem: str,headers: dict, \
f'(request-target): {method.lower()} {path}') f'(request-target): {method.lower()} {path}')
elif signedHeader == 'digest': elif signedHeader == 'digest':
bodyDigest = \ bodyDigest = \
base64.b64encode(SHA256.new(messageBodyJsonStr.encode()).digest()).encode('utf-8') base64.b64encode(SHA256.new(messageBodyJsonStr.encode()).digest()).decode('utf-8')
signedHeaderList.append(f'digest: SHA-256={bodyDigest}') signedHeaderList.append(f'digest: SHA-256={bodyDigest}')
else: else:
if headers.get(signedHeader): if headers.get(signedHeader):