This repository was archived by the owner on Apr 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +6
-25
lines changed
Expand file tree Collapse file tree 4 files changed +6
-25
lines changed Original file line number Diff line number Diff line change 1+ Remove some dead code regarding TLS certificate handling.
Original file line number Diff line number Diff line change @@ -261,13 +261,10 @@ def refresh_certificate(hs):
261261 Refresh the TLS certificates that Synapse is using by re-reading them from
262262 disk and updating the TLS context factories to use them.
263263 """
264-
265264 if not hs .config .has_tls_listener ():
266- # attempt to reload the certs for the good of the tls_fingerprints
267- hs .config .read_certificate_from_disk (require_cert_and_key = False )
268265 return
269266
270- hs .config .read_certificate_from_disk (require_cert_and_key = True )
267+ hs .config .read_certificate_from_disk ()
271268 hs .tls_server_context_factory = context_factory .ServerContextFactory (hs .config )
272269
273270 if hs ._listening_services :
Original file line number Diff line number Diff line change @@ -215,28 +215,12 @@ def is_disk_cert_valid(self, allow_self_signed=True):
215215 days_remaining = (expires_on - now ).days
216216 return days_remaining
217217
218- def read_certificate_from_disk (self , require_cert_and_key : bool ):
218+ def read_certificate_from_disk (self ):
219219 """
220220 Read the certificates and private key from disk.
221-
222- Args:
223- require_cert_and_key: set to True to throw an error if the certificate
224- and key file are not given
225221 """
226- if require_cert_and_key :
227- self .tls_private_key = self .read_tls_private_key ()
228- self .tls_certificate = self .read_tls_certificate ()
229- elif self .tls_certificate_file :
230- # we only need the certificate for the tls_fingerprints. Reload it if we
231- # can, but it's not a fatal error if we can't.
232- try :
233- self .tls_certificate = self .read_tls_certificate ()
234- except Exception as e :
235- logger .info (
236- "Unable to read TLS certificate (%s). Ignoring as no "
237- "tls listeners enabled." ,
238- e ,
239- )
222+ self .tls_private_key = self .read_tls_private_key ()
223+ self .tls_certificate = self .read_tls_certificate ()
240224
241225 def generate_config_section (
242226 self ,
Original file line number Diff line number Diff line change @@ -74,12 +74,11 @@ def test_warn_self_signed(self):
7474
7575 config = {
7676 "tls_certificate_path" : os .path .join (config_dir , "cert.pem" ),
77- "tls_fingerprints" : [],
7877 }
7978
8079 t = TestConfig ()
8180 t .read_config (config , config_dir_path = "" , data_dir_path = "" )
82- t .read_certificate_from_disk ( require_cert_and_key = False )
81+ t .read_tls_certificate ( )
8382
8483 warnings = self .flushWarnings ()
8584 self .assertEqual (len (warnings ), 1 )
You can’t perform that action at this time.
0 commit comments