Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Config option for verifying federation certificates (MSC 1711) #4967

Merged
merged 57 commits into from
Apr 25, 2019

Conversation

anoadragon453
Copy link
Member

@anoadragon453 anoadragon453 commented Mar 28, 2019

Implementation of MSC 1711 for Synapse - aka verifying federation certificates. Adds three new config values:

  • One for verifying certificates
  • One for domains to exempt from the above
  • One for the use of custom CAs

TODO:

  • Enable/disable certificate validation via config
  • Domain whitelist for certificate validation
  • Custom CA list for certificate validation
  • Append new option info to MSC1711 FAQ

Note that certificate validation is currently set to False. I assume we want to change this during the 1.0 release.

Closes #4366

@codecov
Copy link

codecov bot commented Apr 1, 2019

Codecov Report

Merging #4967 into develop will decrease coverage by 0.05%.
The diff coverage is 37.77%.

@@             Coverage Diff             @@
##           develop    #4967      +/-   ##
===========================================
- Coverage    60.63%   60.58%   -0.06%     
===========================================
  Files          332      332              
  Lines        34255    34269      +14     
  Branches      5658     5664       +6     
===========================================
- Hits         20772    20762      -10     
- Misses       12005    12025      +20     
- Partials      1478     1482       +4

@anoadragon453 anoadragon453 requested a review from richvdh April 3, 2019 12:40
@anoadragon453 anoadragon453 dismissed richvdh’s stale review April 3, 2019 12:40

Addressed changes

richvdh
richvdh previously requested changes Apr 4, 2019
docs/MSC1711_certificates_FAQ.md Outdated Show resolved Hide resolved
federation_domain_whitelist = config.get(
"federation_domain_whitelist", None
"federation_domain_whitelist", [],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hrm, could we keep changes to federation_domain_whitelist in a separate PR? there's already quite a lot going on here and it's hard to keep track of an extra dimension of changes.

synapse/config/tls.py Outdated Show resolved Hide resolved
synapse/config/tls.py Show resolved Hide resolved
synapse/config/tls.py Outdated Show resolved Hide resolved
synapse/crypto/context_factory.py Outdated Show resolved Hide resolved
synapse/crypto/context_factory.py Outdated Show resolved Hide resolved
synapse/config/tls.py Outdated Show resolved Hide resolved
synapse/crypto/context_factory.py Show resolved Hide resolved
tests/utils.py Outdated
@@ -137,6 +137,9 @@ def default_config(name):
config.email_enable_notifs = False
config.block_non_admin_invites = False
config.federation_domain_whitelist = None
config.federation_certificate_verification_whitelist = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment at line 126. These lines should be unnecessary. If you want to set the default config for all tests, update the config dict above (and add a comment to justify it)

# of domains.
#
# This setting should only normally be used within a private network of
# homeservers.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree with this warning, there's a bunch of networks where this is useful that aren't private where this is useful. For private networks of homeservers, custom CAs are the right tool, not disabling TLS verification.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcgruenhage can you propose better wording then please.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "This setting should only normally be used within a private network of homeservers, and even then using a private CA should be taken into consideration before disabling TLS verification entirely."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say "This setting should only be used in very specific cases, such as federation over Tor hidden services and similar. For private networks of homeservers, you likely want to use a private CA instead."

#federation_certificate_verification_whitelist:
# - lon.example.com
# - *.domain.com
# - *.onion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nitpicky thing about this whitelist, MSC 1711 also spoke about excluding net masks, not only domains. This seems to not be dealt with at all in this PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd quite like to get this PR landed. Let's descope netmasks for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with that as long as they are still in scope for Synapse 1.0

richvdh
richvdh previously requested changes Apr 8, 2019
@@ -177,7 +177,6 @@ You can do this with a `.well-known` file as follows:
on `customer.example.net:8000` it correctly handles HTTP requests with
Host header set to `customer.example.net:8000`.


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bit pointless, but ok

# of domains.
#
# This setting should only normally be used within a private network of
# homeservers.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcgruenhage can you propose better wording then please.

#federation_certificate_verification_whitelist:
# - lon.example.com
# - *.domain.com
# - *.onion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd quite like to get this PR landed. Let's descope netmasks for now.

@@ -111,13 +111,15 @@ def read_config(self, config):
self.admin_contact = config.get("admin_contact", None)

# FIXME: federation_domain_whitelist needs sytests
self.federation_domain_whitelist = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this code being changed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left over from previous refactor that was reverted. Have changed code back so there's less diff now.

)

# Support globs (*) in whitelist values
self.federation_certificate_verification_whitelist = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for future reference, you could write this:

self.federation_certificate_verification_whitelist = [glob_to_regex(entry) for entry in fed_whitelist_entries]

what you have is fine though.

self.federation_ca_trust_root = None
if custom_ca_list is not None:
if len(custom_ca_list) == 0:
raise ConfigError("federation_custom_ca_list specified without "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a comment as to why this is the right thing to do would be helpful.

@anoadragon453 anoadragon453 dismissed richvdh’s stale review April 8, 2019 12:39

Addressed concerns.

@anoadragon453 anoadragon453 requested a review from richvdh April 8, 2019 12:43
@anoadragon453 anoadragon453 dismissed jcgruenhage’s stale review April 8, 2019 16:59

Updated config string

@babolivier babolivier requested review from a team and removed request for richvdh April 18, 2019 09:49
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@richvdh richvdh merged commit 6824ddd into develop Apr 25, 2019
anoadragon453 added a commit that referenced this pull request Apr 30, 2019
* develop: (34 commits)
  Add a default .m.rule.tombstone push rule (#4867)
  Fix infinite loop in presence handler
  changelog
  more logging improvements
  remove extraneous exception logging
  Clarify logging when PDU signature checking fails
  Changelog
  Add --no-pep-517 to README instructions
  set PIP_USE_PEP517 = False for tests
  Fix handling of SYNAPSE_NO_TLS in docker image (#5005)
  Config option for verifying federation certificates (MSC 1711) (#4967)
  Remove log error for .well-known/matrix/client (#4972)
  Prevent "producer not unregistered" message (#5009)
  add gpg key fingerprint
  Don't crash on lack of expiry templates
  Update debian install docs for new key and repo (#5074)
  Add management endpoints for account validity
  Send out emails with links to extend an account's validity period
  Make sure we're not registering the same 3pid twice
  Newsfile
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants