Merge pull request #279 from mouse-reeve/data-encoding

Stop double-encoding broadcasts
This commit is contained in:
Mouse Reeve 2020-11-02 15:39:51 -08:00 committed by GitHub
commit ce5d847a1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -61,7 +61,7 @@ def broadcast_task(sender_id, activity, recipients):
return errors
def sign_and_send(sender, activity, destination):
def sign_and_send(sender, data, destination):
''' crpyto whatever and http junk '''
now = http_date()
@ -69,7 +69,6 @@ def sign_and_send(sender, activity, destination):
# this shouldn't happen. it would be bad if it happened.
raise ValueError('No private key found for sender')
data = json.dumps(activity).encode('utf-8')
digest = make_digest(data)
response = requests.post(

View file

@ -44,7 +44,8 @@ def make_signature(sender, destination, date, digest):
def make_digest(data):
''' creates a message digest for signing '''
return 'SHA-256=' + b64encode(hashlib.sha256(data).digest()).decode('utf-8')
return 'SHA-256=' + b64encode(hashlib.sha256(data.encode('utf-8'))\
.digest()).decode('utf-8')
def verify_digest(request):