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

Appearance settings

Commit 28e7b74

Browse filesBrowse files
njutn95nicolas-grekas
authored andcommitted
[Messenger] Add rediss:// DSN scheme support for TLS to Redis transport
1 parent 64b7696 commit 28e7b74
Copy full SHA for 28e7b74

File tree

6 files changed

+31
-4
lines changed
Filter options

6 files changed

+31
-4
lines changed

‎UPGRADE-5.3.md

Copy file name to clipboardExpand all lines: UPGRADE-5.3.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Messenger
5050
---------
5151

5252
* Deprecated the `prefetch_count` parameter in the AMQP bridge, it has no effect and will be removed in Symfony 6.0
53+
* Deprecated the use of TLS option for Redis Bridge, use `rediss://127.0.0.1` instead of `redis://127.0.0.1?tls=1`
5354

5455
Notifier
5556
--------

‎UPGRADE-6.0.md

Copy file name to clipboardExpand all lines: UPGRADE-6.0.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ Messenger
122122
* The signature of method `RetryStrategyInterface::isRetryable()` has been updated to `RetryStrategyInterface::isRetryable(Envelope $message, \Throwable $throwable = null)`.
123123
* The signature of method `RetryStrategyInterface::getWaitingTime()` has been updated to `RetryStrategyInterface::getWaitingTime(Envelope $message, \Throwable $throwable = null)`.
124124
* Removed the `prefetch_count` parameter in the AMQP bridge.
125+
* Removed the use of TLS option for Redis Bridge, use `rediss://127.0.0.1` instead of `redis://127.0.0.1?tls=1`
125126

126127
Mime
127128
----

‎src/Symfony/Component/Messenger/Bridge/Redis/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Bridge/Redis/CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
5.3
5+
---
6+
7+
* Add `rediss://` DSN scheme support for TLS protocol
8+
* Deprecate TLS option, use `rediss://127.0.0.1` instead of `redis://127.0.0.1?tls=1`
9+
410
5.2.0
511
-----
612

‎src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/ConnectionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/ConnectionTest.php
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ public function testFromDsnWithOptionsAndTrailingSlash()
8686
);
8787
}
8888

89+
/**
90+
* @group legacy
91+
*/
8992
public function testFromDsnWithTls()
9093
{
9194
$redis = $this->createMock(\Redis::class);
@@ -97,6 +100,9 @@ public function testFromDsnWithTls()
97100
Connection::fromDsn('redis://127.0.0.1?tls=1', [], $redis);
98101
}
99102

103+
/**
104+
* @group legacy
105+
*/
100106
public function testFromDsnWithTlsOption()
101107
{
102108
$redis = $this->createMock(\Redis::class);
@@ -108,6 +114,17 @@ public function testFromDsnWithTlsOption()
108114
Connection::fromDsn('redis://127.0.0.1', ['tls' => true], $redis);
109115
}
110116

117+
public function testFromDsnWithRedissScheme()
118+
{
119+
$redis = $this->createMock(\Redis::class);
120+
$redis->expects($this->once())
121+
->method('connect')
122+
->with('tls://127.0.0.1', 6379)
123+
->willReturn(null);
124+
125+
Connection::fromDsn('rediss://127.0.0.1', [], $redis);
126+
}
127+
111128
public function testFromDsnWithQueryOptions()
112129
{
113130
$this->assertEquals(

‎src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ public function __construct(array $configuration, array $connectionCredentials =
119119
public static function fromDsn(string $dsn, array $redisOptions = [], \Redis $redis = null): self
120120
{
121121
$url = $dsn;
122+
$scheme = 0 === strpos($dsn, 'rediss:') ? 'rediss' : 'redis';
122123

123-
if (preg_match('#^redis:///([^:@])+$#', $dsn)) {
124-
$url = str_replace('redis:', 'file:', $dsn);
124+
if (preg_match('#^'.$scheme.':///([^:@])+$#', $dsn)) {
125+
$url = str_replace($scheme.':', 'file:', $dsn);
125126
}
126127

127128
if (false === $parsedUrl = parse_url($url)) {
@@ -164,8 +165,9 @@ public static function fromDsn(string $dsn, array $redisOptions = [], \Redis $re
164165
unset($redisOptions['dbindex']);
165166
}
166167

167-
$tls = false;
168+
$tls = 'rediss' === $scheme;
168169
if (\array_key_exists('tls', $redisOptions)) {
170+
trigger_deprecation('symfony/redis-messenger', '5.3', 'Providing "tls" parameter is deprecated, use "rediss://" DSN scheme instead');
169171
$tls = filter_var($redisOptions['tls'], \FILTER_VALIDATE_BOOLEAN);
170172
unset($redisOptions['tls']);
171173
}

‎src/Symfony/Component/Messenger/Transport/TransportFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Transport/TransportFactory.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function createTransport(string $dsn, array $options, SerializerInterface
4343
$packageSuggestion = ' Run "composer require symfony/amqp-messenger" to install AMQP transport.';
4444
} elseif (0 === strpos($dsn, 'doctrine://')) {
4545
$packageSuggestion = ' Run "composer require symfony/doctrine-messenger" to install Doctrine transport.';
46-
} elseif (0 === strpos($dsn, 'redis://')) {
46+
} elseif (0 === strpos($dsn, 'redis://') || 0 === strpos($dsn, 'rediss://')) {
4747
$packageSuggestion = ' Run "composer require symfony/redis-messenger" to install Redis transport.';
4848
} elseif (0 === strpos($dsn, 'sqs://') || preg_match('#^https://sqs\.[\w\-]+\.amazonaws\.com/.+#', $dsn)) {
4949
$packageSuggestion = ' Run "composer require symfony/amazon-sqs-messenger" to install Amazon SQS transport.';

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.