mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-14 16:09:34 +00:00
`refresh_certificate` used to build a new `ServerContextFactory` on every SIGHUP and then replace the factory on each listening port with a fresh `TLSMemoryBIOFactory` wrapping the new one, reaching into the port's `factory` attribute to do so. Twisted asks the context factory for a context on every new connection, so rebuilding the `SSL.Context` inside the existing factory is enough for new connections to pick up the new certificate. `start()` now builds the factory once, and `refresh_certificate` is only the SIGHUP handler. This is spawning of #20452: Twisted 26.10 annotates `tcp.Port.factory` as `Factory | None`, and mypy does not accept a `TLSMemoryBIOFactory` there because its protocol type parameter does not match, so the old assignment no longer type-checks. The change removes the assignment rather than suppressing the error. Verified with trial against Twisted 23.8.0 (our minimum declared dep), 26.4.0 (the current version in the lockfile) and 26.10.0 (the next version), and with mypy against 26.4.0 and 26.10.0.