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

Commit 8b8f8c7

Browse files
neilisfragilerichvdh
authored andcommitted
Explicitly log when a homeserver does not have a trusted key server configured (#6090)
1 parent 1b051f1 commit 8b8f8c7

File tree

4 files changed

+63
-16
lines changed

4 files changed

+63
-16
lines changed

changelog.d/6090.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Explicitly log when a homeserver does not have the 'trusted_key_servers' config field configured.

docs/sample_config.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,10 @@ signing_key_path: "CONFDIR/SERVERNAME.signing.key"
10721072
# This setting supercedes an older setting named `perspectives`. The old format
10731073
# is still supported for backwards-compatibility, but it is deprecated.
10741074
#
1075+
# 'trusted_key_servers' defaults to matrix.org, but using it will generate a
1076+
# warning on start-up. To suppress this warning, set
1077+
# 'suppress_key_server_warning' to true.
1078+
#
10751079
# Options for each entry in the list include:
10761080
#
10771081
# server_name: the name of the server. required.
@@ -1096,11 +1100,13 @@ signing_key_path: "CONFDIR/SERVERNAME.signing.key"
10961100
# "ed25519:auto": "abcdefghijklmnopqrstuvwxyzabcdefghijklmopqr"
10971101
# - server_name: "my_other_trusted_server.example.com"
10981102
#
1099-
# The default configuration is:
1100-
#
1101-
#trusted_key_servers:
1102-
# - server_name: "matrix.org"
1103+
trusted_key_servers:
1104+
- server_name: "matrix.org"
1105+
1106+
# Uncomment the following to disable the warning that is emitted when the
1107+
# trusted_key_servers include 'matrix.org'. See above.
11031108
#
1109+
#suppress_key_server_warning: true
11041110

11051111
# The signing keys to use when acting as a trusted key server. If not specified
11061112
# defaults to the server signing key.

synapse/config/key.py

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,33 @@
5050
If you are *sure* you want to do this, set 'accept_keys_insecurely' on the
5151
trusted_key_server configuration."""
5252

53+
TRUSTED_KEY_SERVER_NOT_CONFIGURED_WARN = """\
54+
Synapse requires that a list of trusted key servers are specified in order to
55+
provide signing keys for other servers in the federation.
56+
57+
This homeserver does not have a trusted key server configured in
58+
homeserver.yaml and will fall back to the default of 'matrix.org'.
59+
60+
Trusted key servers should be long-lived and stable which makes matrix.org a
61+
good choice for many admins, but some admins may wish to choose another. To
62+
suppress this warning, the admin should set 'trusted_key_servers' in
63+
homeserver.yaml to their desired key server and 'suppress_key_server_warning'
64+
to 'true'.
65+
66+
In a future release the software-defined default will be removed entirely and
67+
the trusted key server will be defined exclusively by the value of
68+
'trusted_key_servers'.
69+
--------------------------------------------------------------------------------"""
70+
71+
TRUSTED_KEY_SERVER_CONFIGURED_AS_M_ORG_WARN = """\
72+
This server is configured to use 'matrix.org' as its trusted key server via the
73+
'trusted_key_servers' config option. 'matrix.org' is a good choice for a key
74+
server since it is long-lived, stable and trusted. However, some admins may
75+
wish to use another server for this purpose.
76+
77+
To suppress this warning and continue using 'matrix.org', admins should set
78+
'suppress_key_server_warning' to 'true' in homeserver.yaml.
79+
--------------------------------------------------------------------------------"""
5380

5481
logger = logging.getLogger(__name__)
5582

@@ -85,6 +112,7 @@ def read_config(self, config, config_dir_path, **kwargs):
85112
config.get("key_refresh_interval", "1d")
86113
)
87114

115+
suppress_key_server_warning = config.get("suppress_key_server_warning", False)
88116
key_server_signing_keys_path = config.get("key_server_signing_keys_path")
89117
if key_server_signing_keys_path:
90118
self.key_server_signing_keys = self.read_signing_keys(
@@ -95,6 +123,7 @@ def read_config(self, config, config_dir_path, **kwargs):
95123

96124
# if neither trusted_key_servers nor perspectives are given, use the default.
97125
if "perspectives" not in config and "trusted_key_servers" not in config:
126+
logger.warn(TRUSTED_KEY_SERVER_NOT_CONFIGURED_WARN)
98127
key_servers = [{"server_name": "matrix.org"}]
99128
else:
100129
key_servers = config.get("trusted_key_servers", [])
@@ -108,6 +137,11 @@ def read_config(self, config, config_dir_path, **kwargs):
108137
# merge the 'perspectives' config into the 'trusted_key_servers' config.
109138
key_servers.extend(_perspectives_to_key_servers(config))
110139

140+
if not suppress_key_server_warning and "matrix.org" in (
141+
s["server_name"] for s in key_servers
142+
):
143+
logger.warning(TRUSTED_KEY_SERVER_CONFIGURED_AS_M_ORG_WARN)
144+
111145
# list of TrustedKeyServer objects
112146
self.key_servers = list(
113147
_parse_key_servers(key_servers, self.federation_verify_certificates)
@@ -190,6 +224,10 @@ def generate_config_section(
190224
# This setting supercedes an older setting named `perspectives`. The old format
191225
# is still supported for backwards-compatibility, but it is deprecated.
192226
#
227+
# 'trusted_key_servers' defaults to matrix.org, but using it will generate a
228+
# warning on start-up. To suppress this warning, set
229+
# 'suppress_key_server_warning' to true.
230+
#
193231
# Options for each entry in the list include:
194232
#
195233
# server_name: the name of the server. required.
@@ -214,11 +252,13 @@ def generate_config_section(
214252
# "ed25519:auto": "abcdefghijklmnopqrstuvwxyzabcdefghijklmopqr"
215253
# - server_name: "my_other_trusted_server.example.com"
216254
#
217-
# The default configuration is:
218-
#
219-
#trusted_key_servers:
220-
# - server_name: "matrix.org"
255+
trusted_key_servers:
256+
- server_name: "matrix.org"
257+
258+
# Uncomment the following to disable the warning that is emitted when the
259+
# trusted_key_servers include 'matrix.org'. See above.
221260
#
261+
#suppress_key_server_warning: true
222262
223263
# The signing keys to use when acting as a trusted key server. If not specified
224264
# defaults to the server signing key.

synapse/config/server.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@
4848
"to join this room."
4949
)
5050

51+
METRICS_PORT_WARNING = """\
52+
The metrics_port configuration option is deprecated in Synapse 0.31 in favour of
53+
a listener. Please see
54+
https://github.com/matrix-org/synapse/blob/master/docs/metrics-howto.md
55+
on how to configure the new listener.
56+
--------------------------------------------------------------------------------"""
57+
5158

5259
class ServerConfig(Config):
5360
def read_config(self, config, **kwargs):
@@ -341,14 +348,7 @@ class LimitRemoteRoomsConfig(object):
341348

342349
metrics_port = config.get("metrics_port")
343350
if metrics_port:
344-
logger.warn(
345-
(
346-
"The metrics_port configuration option is deprecated in Synapse 0.31 "
347-
"in favour of a listener. Please see "
348-
"http://github.com/matrix-org/synapse/blob/master/docs/metrics-howto.md"
349-
" on how to configure the new listener."
350-
)
351-
)
351+
logger.warning(METRICS_PORT_WARNING)
352352

353353
self.listeners.append(
354354
{

0 commit comments

Comments
 (0)