Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Cache] Fix Redis TLS schemerediss for Redis connection#39599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:4.4frommisaert:feat-add-tls-to-redis-cache-adapter
Feb 22, 2021
Merged

[Cache] Fix Redis TLS schemerediss for Redis connection#39599

nicolas-grekas merged 1 commit intosymfony:4.4frommisaert:feat-add-tls-to-redis-cache-adapter
Feb 22, 2021

Conversation

@misaert
Copy link
Contributor

@misaertmisaert commentedDec 21, 2020
edited
Loading

QA
Branch?5.x
Bug fix?yes
New feature?no
Deprecations?no
Tickets
LicenseMIT
Doc PRsymfony/symfony-docs#14728

Like#35503 on Symfony Messenger, this will enable TLS support for Redis adapter.

The implementation just prefix the host withtls:// as described here:https://github.com/phpredis/phpredis#connect-open

I don't know how to test it because I guess I need a TLS Redis insrc/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 5.x branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@njutn95
Copy link
Contributor

Tested the code, and it's working.

Copy link
Member

@jderussejderusse left a comment

Choose a reason for hiding this comment

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

would be great to use the github action test suite and one of the running container to provide functional tests.

@jderusse
Copy link
Member

If we add a new parametertls in query string, what is the purpose ofrediss://? /cc@nicolas-grekas

@njutn95
Copy link
Contributor

There really is no difference betweenredis andrediss at the moment, they're acting in exactly the same way. So you're right, usingrediss:// would be a better option.

@jderusse
Copy link
Member

From thepredis Readme:

Same set of parameters, but using an URI string:
$client = new Predis\Client('tls://127.0.0.1?ssl[cafile]=private.pem&ssl[verify_peer]=1');
The connection schemes redis (alias of tcp) and rediss (alias of tls) are also supported, with the difference that URI strings containing these schemes are parsed following the rules described on their respective IANA provisional registration documents.

IMHO the fix should be about keeping the scheme defined here:

if (0 ===strpos($dsn,'redis:')) {
$scheme ='redis';
}elseif (0 ===strpos($dsn,'rediss:')) {
$scheme ='rediss';
}else {

And use that scheme in the relevant places:

@njutn95
Copy link
Contributor

Forphpredis to work, it requires the use oftls://127.0.0.1. However, forpredis, you can usetls:// orrediss:// (which is an alias fortls:// as it's said in the Predis README you mentioned). So we can't actually use the scheme for connecting withphpredis, but it can be used forpredis though.

@misaert
Copy link
ContributorAuthor

Forphpredis to work, it requires the use oftls://127.0.0.1. However, forpredis, you can usetls:// orrediss:// (which is an alias fortls:// as it's said in the Predis README you mentioned). So we can't actually use the scheme for connecting withphpredis, but it can be used forpredis though.

And it doesn't work with the same DSN on Symfony Messenger because ofhttps://github.com/symfony/messenger/blob/5.x/Transport/TransportFactory.php#L46:

  [Symfony\Component\Messenger\Exception\InvalidArgumentException]                                                                                                     No transport supports the given Messenger DSN "rediss://<...>"

@jderusse
Copy link
Member

I don't have strong opinion aboutrediss:// vs?tls= but IMHO this should be consistent across all components:
I suggest to:

  • deprecates either?tls in messenger orrediss:// in cache, lock, session
  • in all cases fix RedisTrait

Given The RedisTrait didn't work, maybe it's easier to deprecate therediss:// scheme? @symfony/mergers

@njutn95
Copy link
Contributor

I've created a PR to addrediss:// support to the Messenger (which is really going to be an alias totls=1), without deprecating thetls option (yet). Either way, it should definitely be standardized one way or another (or to support both).

@derrabus
Copy link
Member

derrabus commentedDec 22, 2020
edited
Loading

For reference, a codebase I took over recently uses this bundle to configure their redis connections:https://github.com/snc/SncRedisBundle

The developers told me that they in favor of that bundle mainly because it allowed them to configure TLS connections, which is a requirement when using the managed Redis services of our current hoster Digital Ocean. Our DSNs are all configured with therediss scheme,but if I understood the bundle corectly, it mainly passes the DSN down to Predis. I got that wrong, thanks@njutn95 for the correction.

@njutn95
Copy link
Contributor

SncRedisBundle is indeed reading the TLS configuration from therediss:// scheme

derrabus reacted with thumbs up emoji

@nicolas-grekasnicolas-grekas added this to the5.x milestoneDec 23, 2020
@misaert
Copy link
ContributorAuthor

I've created a PR to addrediss:// support to the Messenger (which is really going to be an alias totls=1), without deprecating thetls option (yet). Either way, it should definitely be standardized one way or another (or to support both).

For now, I changed the code to support both.rediss DSN sheme changes Redis scheme bytls (for Predis particularly) and adds the prefixtls:// in host for Redis extension.

Copy link
Member

@jderussejderusse left a comment

Choose a reason for hiding this comment

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

Eithertls option should not be added here,rediss scheme should be deprecated.

We should not support both.

@misaert
Copy link
ContributorAuthor

Eithertls option should not be added here,rediss scheme should be deprecated.

We should not support both.

To be consistent with#39607, I keep therediss scheme for TLS and removed the option.

@misaertmisaert changed the title[Cache] Add TLS option for Redis connection[Cache] Fix Redis TLS schemerediss for Redis connectionDec 25, 2020
@stof
Copy link
Member

@nicolas-grekas I would vote for merging that in 4.4 as a bugfix, as symfony/cache claims to supportrediss in 4.4 already. Supportingrediss without actually enabling TLS qualifies as a bug to me.

njutn95, derrabus, and chalasr reacted with thumbs up emoji

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

(I rebased on 4.4, cleaned up implementation a bit and fixed tests)

misaert reacted with thumbs up emoji
@nicolas-grekasnicolas-grekas merged commit1688e5d intosymfony:4.4Feb 22, 2021
nicolas-grekas added a commit that referenced this pull requestFeb 26, 2021
… to Redis transport (njutn95)This PR was squashed before being merged into the 5.3-dev branch.Discussion----------[Messenger] Add `rediss://` DSN scheme support for TLS to Redis transport| Q             | A| ------------- | ---| Branch?       | 5.x| Bug fix?      | no| New feature?  | no| Deprecations? | yes| Tickets       || License       | MIT| Doc PR        |This adds a support for `rediss://` DSN (as discussed in#39599) and deprecates the use of `tls` parameter introduced in#35503 so it can be standardized to single format.Commits-------28e7b74 [Messenger] Add `rediss://` DSN scheme support for TLS to Redis transport
This was referencedMar 4, 2021
wouterj added a commit to symfony/symfony-docs that referenced this pull requestApr 7, 2021
This PR was merged into the 4.4 branch.Discussion----------[Cache] Add TLS scheme for Redis connectionSeesymfony/symfony#39599.Commits-------2d2f3b7 [Cache] Add TLS scheme for Redis connection
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@jderussejderusseAwaiting requested review from jderusse

@chalasrchalasrAwaiting requested review from chalasr

@dunglasdunglasAwaiting requested review from dunglas

@lyrixxlyrixxAwaiting requested review from lyrixx

@srozesrozeAwaiting requested review from sroze

@wouterjwouterjAwaiting requested review from wouterj

@xabbuhxabbuhAwaiting requested review from xabbuh

@ycerutoycerutoAwaiting requested review from yceruto

+1 more reviewer

@njutn95njutn95njutn95 left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

7 participants

@misaert@carsonbot@njutn95@jderusse@derrabus@stof@nicolas-grekas

[8]ページ先頭

©2009-2025 Movatter.jp