Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
Move ClientTLSOptionsFactory init out of refresh_certificates (#4611)
Browse files Browse the repository at this point in the history
It's nothing to do with refreshing the certificates. No idea why it was here.
  • Loading branch information
richvdh committed Feb 11, 2019
1 parent 719e073 commit 5d27730
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions changelog.d/4611.misc
@@ -0,0 +1 @@
Move ClientTLSOptionsFactory init out of refresh_certificates
3 changes: 0 additions & 3 deletions synapse/app/_base.py
Expand Up @@ -216,9 +216,6 @@ def refresh_certificate(hs):
logging.info("Loading certificate from disk...")
hs.config.read_certificate_from_disk()
hs.tls_server_context_factory = context_factory.ServerContextFactory(hs.config)
hs.tls_client_options_factory = context_factory.ClientTLSOptionsFactory(
hs.config
)
logging.info("Certificate loaded.")

if hs._listening_services:
Expand Down
4 changes: 2 additions & 2 deletions synapse/http/matrixfederationclient.py
Expand Up @@ -168,15 +168,15 @@ class MatrixFederationHttpClient(object):
requests.
"""

def __init__(self, hs):
def __init__(self, hs, tls_client_options_factory):
self.hs = hs
self.signing_key = hs.config.signing_key[0]
self.server_name = hs.hostname
reactor = hs.get_reactor()

self.agent = MatrixFederationAgent(
hs.get_reactor(),
hs.tls_client_options_factory,
tls_client_options_factory,
)
self.clock = hs.get_clock()
self._store = hs.get_datastore()
Expand Down
6 changes: 5 additions & 1 deletion synapse/server.py
Expand Up @@ -31,6 +31,7 @@
from synapse.api.ratelimiting import Ratelimiter
from synapse.appservice.api import ApplicationServiceApi
from synapse.appservice.scheduler import ApplicationServiceScheduler
from synapse.crypto import context_factory
from synapse.crypto.keyring import Keyring
from synapse.events.builder import EventBuilderFactory
from synapse.events.spamcheck import SpamChecker
Expand Down Expand Up @@ -367,7 +368,10 @@ def build_pusherpool(self):
return PusherPool(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):
name = self.db_config["name"]
Expand Down
4 changes: 1 addition & 3 deletions tests/http/test_fedclient.py
Expand Up @@ -43,13 +43,11 @@ def check_logcontext(context):

class FederationClientTests(HomeserverTestCase):
def make_homeserver(self, reactor, clock):

hs = self.setup_test_homeserver(reactor=reactor, clock=clock)
hs.tls_client_options_factory = None
return hs

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"

def test_client_get(self):
Expand Down

0 comments on commit 5d27730

Please sign in to comment.