summary refs log tree commit diff
path: root/synapse/app/_base.py
diff options
context:
space:
mode:
authorAmber Brown <hawkowl@atleastfornow.net>2019-02-11 21:36:26 +1100
committerRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2019-02-11 10:36:26 +0000
commit6e2a5aa050fc132a7dee6b3e33a7a368207d7e5a (patch)
tree7c30cc2c0fe48d3e5c0513565a390b5572d9248a /synapse/app/_base.py
parentBe tolerant of blank TLS fingerprints config (#4589) (diff)
downloadsynapse-6e2a5aa050fc132a7dee6b3e33a7a368207d7e5a.tar.xz
ACME Reprovisioning (#4522)
Diffstat (limited to 'synapse/app/_base.py')
-rw-r--r--synapse/app/_base.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/synapse/app/_base.py b/synapse/app/_base.py
index 3cbb003035..62c633146f 100644
--- a/synapse/app/_base.py
+++ b/synapse/app/_base.py
@@ -23,6 +23,7 @@ import psutil
 from daemonize import Daemonize
 
 from twisted.internet import error, reactor
+from twisted.protocols.tls import TLSMemoryBIOFactory
 
 from synapse.app import check_bind_error
 from synapse.crypto import context_factory
@@ -220,6 +221,24 @@ def refresh_certificate(hs):
     )
     logging.info("Certificate loaded.")
 
+    if hs._listening_services:
+        logging.info("Updating context factories...")
+        for i in hs._listening_services:
+            # When you listenSSL, it doesn't make an SSL port but a TCP one with
+            # a TLS wrapping factory around the factory you actually want to get
+            # requests. This factory attribute is public but missing from
+            # Twisted's documentation.
+            if isinstance(i.factory, TLSMemoryBIOFactory):
+                # We want to replace TLS factories with a new one, with the new
+                # TLS configuration. We do this by reaching in and pulling out
+                # the wrappedFactory, and then re-wrapping it.
+                i.factory = TLSMemoryBIOFactory(
+                    hs.tls_server_context_factory,
+                    False,
+                    i.factory.wrappedFactory
+                )
+        logging.info("Context factories updated.")
+
 
 def start(hs, listeners=None):
     """