Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit b7e4bfd

Browse files
authored
Fix a bug where Synapse fails to start if a signing key file contains an empty line. (#13738)
1 parent d4d3249 commit b7e4bfd

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

changelog.d/13738.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug where Synapse fails to start if a signing key file contains an empty line.

synapse/config/key.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,18 @@ def read_signing_keys(self, signing_key_path: str, name: str) -> List[SigningKey
217217

218218
signing_keys = self.read_file(signing_key_path, name)
219219
try:
220-
return read_signing_keys(signing_keys.splitlines(True))
220+
loaded_signing_keys = read_signing_keys(
221+
[
222+
signing_key_line
223+
for signing_key_line in signing_keys.splitlines(keepends=False)
224+
if signing_key_line.strip()
225+
]
226+
)
227+
228+
if not loaded_signing_keys:
229+
raise ConfigError(f"No signing keys in file {signing_key_path}")
230+
231+
return loaded_signing_keys
221232
except Exception as e:
222233
raise ConfigError("Error reading %s: %s" % (name, str(e)))
223234

0 commit comments

Comments
 (0)