summary refs log tree commit diff
path: root/synapse/config/key.py
diff options
context:
space:
mode:
authorreivilibre <oliverw@matrix.org>2022-09-08 10:18:03 +0000
committerGitHub <noreply@github.com>2022-09-08 11:18:03 +0100
commitb7e4bfd005a804ed0cd3d204c367b11565b76df6 (patch)
treeecbd014e3def15c519164aba7b12f831c5f703bc /synapse/config/key.py
parentInstrument `get_metadata_for_events` for tracing (#13730) (diff)
downloadsynapse-b7e4bfd005a804ed0cd3d204c367b11565b76df6.tar.xz
Fix a bug where Synapse fails to start if a signing key file contains an empty line. (#13738)
Diffstat (limited to '')
-rw-r--r--synapse/config/key.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/synapse/config/key.py b/synapse/config/key.py
index cc75efdf8f..f3dc4df695 100644
--- a/synapse/config/key.py
+++ b/synapse/config/key.py
@@ -217,7 +217,18 @@ class KeyConfig(Config):
 
         signing_keys = self.read_file(signing_key_path, name)
         try:
-            return read_signing_keys(signing_keys.splitlines(True))
+            loaded_signing_keys = read_signing_keys(
+                [
+                    signing_key_line
+                    for signing_key_line in signing_keys.splitlines(keepends=False)
+                    if signing_key_line.strip()
+                ]
+            )
+
+            if not loaded_signing_keys:
+                raise ConfigError(f"No signing keys in file {signing_key_path}")
+
+            return loaded_signing_keys
         except Exception as e:
             raise ConfigError("Error reading %s: %s" % (name, str(e)))