Move ClientTLSOptionsFactory init out of refresh_certificates (#4611)

It's nothing to do with refreshing the certificates. No idea why it was here.
pull/4614/head
Richard van der Hoff 2019-02-11 18:03:30 +00:00 committed by GitHub
parent 719e073f00
commit 5d27730a73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 9 deletions

1
changelog.d/4611.misc Normal file
View File

@ -0,0 +1 @@
Move ClientTLSOptionsFactory init out of refresh_certificates

View File

@ -216,9 +216,6 @@ def refresh_certificate(hs):
logging.info("Loading certificate from disk...") logging.info("Loading certificate from disk...")
hs.config.read_certificate_from_disk() hs.config.read_certificate_from_disk()
hs.tls_server_context_factory = context_factory.ServerContextFactory(hs.config) hs.tls_server_context_factory = context_factory.ServerContextFactory(hs.config)
hs.tls_client_options_factory = context_factory.ClientTLSOptionsFactory(
hs.config
)
logging.info("Certificate loaded.") logging.info("Certificate loaded.")
if hs._listening_services: if hs._listening_services:

View File

@ -168,7 +168,7 @@ class MatrixFederationHttpClient(object):
requests. requests.
""" """
def __init__(self, hs): def __init__(self, hs, tls_client_options_factory):
self.hs = hs self.hs = hs
self.signing_key = hs.config.signing_key[0] self.signing_key = hs.config.signing_key[0]
self.server_name = hs.hostname self.server_name = hs.hostname
@ -176,7 +176,7 @@ class MatrixFederationHttpClient(object):
self.agent = MatrixFederationAgent( self.agent = MatrixFederationAgent(
hs.get_reactor(), hs.get_reactor(),
hs.tls_client_options_factory, tls_client_options_factory,
) )
self.clock = hs.get_clock() self.clock = hs.get_clock()
self._store = hs.get_datastore() self._store = hs.get_datastore()

View File

@ -31,6 +31,7 @@ from synapse.api.filtering import Filtering
from synapse.api.ratelimiting import Ratelimiter from synapse.api.ratelimiting import Ratelimiter
from synapse.appservice.api import ApplicationServiceApi from synapse.appservice.api import ApplicationServiceApi
from synapse.appservice.scheduler import ApplicationServiceScheduler from synapse.appservice.scheduler import ApplicationServiceScheduler
from synapse.crypto import context_factory
from synapse.crypto.keyring import Keyring from synapse.crypto.keyring import Keyring
from synapse.events.builder import EventBuilderFactory from synapse.events.builder import EventBuilderFactory
from synapse.events.spamcheck import SpamChecker from synapse.events.spamcheck import SpamChecker
@ -367,7 +368,10 @@ class HomeServer(object):
return PusherPool(self) return PusherPool(self)
def build_http_client(self): def build_http_client(self):
return MatrixFederationHttpClient(self) tls_client_options_factory = context_factory.ClientTLSOptionsFactory(
self.config
)
return MatrixFederationHttpClient(self, tls_client_options_factory)
def build_db_pool(self): def build_db_pool(self):
name = self.db_config["name"] name = self.db_config["name"]

View File

@ -43,13 +43,11 @@ def check_logcontext(context):
class FederationClientTests(HomeserverTestCase): class FederationClientTests(HomeserverTestCase):
def make_homeserver(self, reactor, clock): def make_homeserver(self, reactor, clock):
hs = self.setup_test_homeserver(reactor=reactor, clock=clock) hs = self.setup_test_homeserver(reactor=reactor, clock=clock)
hs.tls_client_options_factory = None
return hs return hs
def prepare(self, reactor, clock, homeserver): def prepare(self, reactor, clock, homeserver):
self.cl = MatrixFederationHttpClient(self.hs) self.cl = MatrixFederationHttpClient(self.hs, None)
self.reactor.lookups["testserv"] = "1.2.3.4" self.reactor.lookups["testserv"] = "1.2.3.4"
def test_client_get(self): def test_client_get(self):