summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
Diffstat (limited to 'synapse')
-rw-r--r--synapse/crypto/event_signing.py6
-rw-r--r--synapse/federation/units.py2
2 files changed, 6 insertions, 2 deletions
diff --git a/synapse/crypto/event_signing.py b/synapse/crypto/event_signing.py
index a236f7d708..d3b501c6e7 100644
--- a/synapse/crypto/event_signing.py
+++ b/synapse/crypto/event_signing.py
@@ -22,6 +22,9 @@ from syutil.base64util import encode_base64, decode_base64
 from syutil.crypto.jsonsign import sign_json, verify_signed_json
 
 import hashlib
+import logging
+
+logger = logging.getLogger(__name__)
 
 
 def add_event_pdu_content_hash(pdu, hash_algorithm=hashlib.sha256):
@@ -48,7 +51,7 @@ def check_event_pdu_content_hash(pdu, hash_algorithm=hashlib.sha256):
 def _compute_content_hash(pdu, hash_algorithm):
     pdu_json = pdu.get_dict()
     #TODO: Make "age_ts" key internal
-    pdu_json.pop("age_ts")
+    pdu_json.pop("age_ts", None)
     pdu_json.pop("unsigned", None)
     pdu_json.pop("signatures", None)
     hashes = pdu_json.pop("hashes", {})
@@ -60,6 +63,7 @@ def compute_pdu_event_reference_hash(pdu, hash_algorithm=hashlib.sha256):
     tmp_pdu = Pdu(**pdu.get_dict())
     tmp_pdu = prune_pdu(tmp_pdu)
     pdu_json = tmp_pdu.get_dict()
+    pdu_json.pop("signatures", None)
     pdu_json_bytes = encode_canonical_json(pdu_json)
     hashed = hash_algorithm(pdu_json_bytes)
     return (hashed.name, hashed.digest())
diff --git a/synapse/federation/units.py b/synapse/federation/units.py
index b81e162512..b779d259bd 100644
--- a/synapse/federation/units.py
+++ b/synapse/federation/units.py
@@ -101,7 +101,7 @@ class Pdu(JsonEncodedObject):
 
         super(Pdu, self).__init__(
             destinations=destinations,
-            is_state=is_state,
+            is_state=bool(is_state),
             prev_pdus=prev_pdus,
             outlier=outlier,
             hashes=hashes,