summary refs log tree commit diff
path: root/synapse/config/key.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2019-06-21 23:39:08 +0100
committerRichard van der Hoff <richard@matrix.org>2019-06-24 14:14:52 +0100
commit7c2f8881a955a509a4137119128974c4a58a9b88 (patch)
tree3d7c1964d9bfafe49020c80f60692dc7a3095409 /synapse/config/key.py
parentMerge pull request #5516 from matrix-org/rav/acme_key_path (diff)
downloadsynapse-7c2f8881a955a509a4137119128974c4a58a9b88.tar.xz
Ensure that all config options have sensible defaults
This will enable us to skip the unintuitive behaviour where the generated
config and default config are the same thing.
Diffstat (limited to 'synapse/config/key.py')
-rw-r--r--synapse/config/key.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/synapse/config/key.py b/synapse/config/key.py
index e58638f708..5ec465b196 100644
--- a/synapse/config/key.py
+++ b/synapse/config/key.py
@@ -65,13 +65,18 @@ class TrustedKeyServer(object):
 
 
 class KeyConfig(Config):
-    def read_config(self, config, **kwargs):
+    def read_config(self, config, config_dir_path, **kwargs):
         # the signing key can be specified inline or in a separate file
         if "signing_key" in config:
             self.signing_key = read_signing_keys([config["signing_key"]])
         else:
-            self.signing_key_path = config["signing_key_path"]
-            self.signing_key = self.read_signing_key(self.signing_key_path)
+            signing_key_path = config.get("signing_key_path")
+            if signing_key_path is None:
+                signing_key_path = os.path.join(
+                    config_dir_path, config["server_name"] + ".signing.key"
+                )
+
+            self.signing_key = self.read_signing_key(signing_key_path)
 
         self.old_signing_keys = self.read_old_signing_keys(
             config.get("old_signing_keys", {})
@@ -237,8 +242,15 @@ class KeyConfig(Config):
                 )
         return keys
 
-    def generate_files(self, config):
-        signing_key_path = config["signing_key_path"]
+    def generate_files(self, config, config_dir_path):
+        if "signing_key" in config:
+            return
+
+        signing_key_path = config.get("signing_key_path")
+        if signing_key_path is None:
+            signing_key_path = os.path.join(
+                config_dir_path, config["server_name"] + ".signing.key"
+            )
 
         if not self.path_exists(signing_key_path):
             print("Generating signing key file %s" % (signing_key_path,))