summary refs log tree commit diff
path: root/synapse/federation/pdu_codec.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2014-10-16 00:09:48 +0100
committerMark Haines <mark.haines@matrix.org>2014-10-16 00:09:48 +0100
commit66104da10c4191aa1e048f2379190574755109e6 (patch)
tree6b98f50ebaef2b75c78368174ddb939c3e95200e /synapse/federation/pdu_codec.py
parentpersist hashes and origin signatures for PDUs (diff)
downloadsynapse-66104da10c4191aa1e048f2379190574755109e6.tar.xz
Sign outgoing PDUs.
Diffstat (limited to 'synapse/federation/pdu_codec.py')
-rw-r--r--synapse/federation/pdu_codec.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/synapse/federation/pdu_codec.py b/synapse/federation/pdu_codec.py
index cef61108dd..bcac5f9ae8 100644
--- a/synapse/federation/pdu_codec.py
+++ b/synapse/federation/pdu_codec.py
@@ -14,6 +14,7 @@
 # limitations under the License.
 
 from .units import Pdu
+from synapse.crypto.event_signing import hash_event_pdu, sign_event_pdu
 
 import copy
 
@@ -33,6 +34,7 @@ def encode_event_id(pdu_id, origin):
 class PduCodec(object):
 
     def __init__(self, hs):
+        self.signing_key = hs.config.signing_key[0]
         self.server_name = hs.hostname
         self.event_factory = hs.get_event_factory()
         self.clock = hs.get_clock()
@@ -99,4 +101,6 @@ class PduCodec(object):
         if "ts" not in kwargs:
             kwargs["ts"] = int(self.clock.time_msec())
 
-        return Pdu(**kwargs)
+        pdu = Pdu(**kwargs)
+        pdu = hash_event_pdu(pdu)
+        return sign_event_pdu(pdu, self.server_name, self.signing_key)