This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add redis SSL configuration options #15312
Merged
reivilibre
merged 11 commits into
matrix-org:develop
from
roeltm:add-ssl-options-to-redis
May 11, 2023
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2cfd40e
Add SSL options to redis config
roeltm 401af4e
fix lint issues
roeltm 29bc340
Add documentation and changelog file
roeltm 66f9b8f
add missing . at the end of the changelog
roeltm 873c3c0
Merge branch 'develop' into add-ssl-options-to-redis
roeltm 3e4faf2
Move client context factory to new file
roeltm 9deb410
Rename ssl to tls and fix typo
roeltm 4411ee3
fix lint issues
roeltm 55cc759
Merge branch 'develop' into add-ssl-options-to-redis
roeltm 2392bfd
Merge branch 'develop' into add-ssl-options-to-redis
roeltm a4c82c4
Added when redis attributes were added
roeltm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add redis TLS configuration options. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright 2023 The Matrix.org Foundation C.I.C. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
from OpenSSL.SSL import Context | ||
from twisted.internet import ssl | ||
|
||
from synapse.config.redis import RedisConfig | ||
|
||
|
||
class ClientContextFactory(ssl.ClientContextFactory): | ||
def __init__(self, redis_config: RedisConfig): | ||
self.redis_config = redis_config | ||
|
||
def getContext(self) -> Context: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm slightly suspicious of Before merging, we should check the correct TLS verification flags are set on this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I looked into this and it seems sane. Notably, it's the Twisted SSL context, not the vanilla Python one 😵💫.) |
||
ctx = super().getContext() | ||
if self.redis_config.redis_certificate: | ||
ctx.use_certificate_file(self.redis_config.redis_certificate) | ||
if self.redis_config.redis_private_key: | ||
ctx.use_privatekey_file(self.redis_config.redis_private_key) | ||
if self.redis_config.redis_ca_file: | ||
ctx.load_verify_locations(cafile=self.redis_config.redis_ca_file) | ||
elif self.redis_config.redis_ca_path: | ||
ctx.load_verify_locations(capath=self.redis_config.redis_ca_path) | ||
return ctx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing this refers to the
dbid
option specifically?We should have explicitly point out when the new options were added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes, that's a good point, I didn't spot that since it was floating.
I guess it would be sensible to put
_Added in Synapse 1.78.0._
on the original options and add (I believe)_Added in Synapse 1.83.0._
on the new ones.Otherwise might be worth seeing what the other option groups do if the 'sub-options' were added at different times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If in doubt, my advice would be to copy what the Python docs do, e.g. https://docs.python.org/3/library/subprocess.html?highlight=subprocess#subprocess.TimeoutExpired
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the changelog with version. I used version 1.84.0, since 1.83.0 is already in RC so I assume it won't end up in that one.