element-hq / element-hq/synapse

adopt new Twisted TLS APIs

Open
#1,691 0 comments 1 reaction 0 assignees View on GitHub
T-Enhancement
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

This issue has been migrated from [#1691](https://github.com/matrix-org/synapse/issues/1691).

---

The code in Synapse uses a subclass of `ssl.ContextFactory` with some manual OpenSSL setup.

Twisted will do quite a lot of this for you (more every day!) and can handle several things that it looks like Synapse isn't doing right now, like service identity validation and [sending server name indication](https://github.com/matrix-org/synapse/issues/1491).

The relevant APIs are:

- Implement [`twisted.internet.interfaces.IOpenSSLClientConnectionCreator`](https://twistedmatrix.com/documents/16.6.0/api/twisted.internet.interfaces.IOpenSSLClientConnectionCreator.html) or [`twisted.internet.interfaces.IOpenSSLServerConnectionCreator`](https://twistedmatrix.com/documents/16.6.0/api/twisted.internet.interfaces.IOpenSSLServerConnectionCreator.html) rather than subclassing `ContextFactory` if you need to do your own thing.
- Consider using [`optionsForClientTLS`](https://twistedmatrix.com/documents/16.6.0/api/twisted.internet.ssl.html#optionsForClientTLS) for clients, or [`CertificateOptions`](https://twistedmatrix.com/documents/16.6.0/api/twisted.internet.ssl.CertificateOptions.html) (sorry - horrible class name there, I know) for servers, if the default behavior is good enough.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.