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

Commit

Permalink
Fix a bug where Synapse fails to start if a signing key file contains…
Browse files Browse the repository at this point in the history
… an empty line. (#13738)
  • Loading branch information
reivilibre committed Sep 8, 2022
1 parent d4d3249 commit b7e4bfd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/13738.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug where Synapse fails to start if a signing key file contains an empty line.
13 changes: 12 additions & 1 deletion synapse/config/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,18 @@ def read_signing_keys(self, signing_key_path: str, name: str) -> List[SigningKey

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)))

Expand Down

0 comments on commit b7e4bfd

Please sign in to comment.