Skip to content

Add options to force TLS Version in the connection string #658

@lbassin

Description

@lbassin

Hi guys,
I've been dealing with an issue that is not directly related to this bundle
If you want more details phpredis/phpredis#1726 and https://bugs.php.net/bug.php?id=79501

TL;DR with PHP >= 7.4, tls v1.3 is used by default and seems to result in random frozen connections (Both Predis and PHPRedis sa it's at the php layer)
The quick fix in the meanwhile is to force the connection to use tls 1.2, this is achieved by using the following connection string tlsv1.2://my-redis-server:6379 instead of tls://my-redis-server:6379

After looking at the factories, the change is pretty basic to do
Here: https://github.com/snc/SncRedisBundle/blob/master/src/Factory/PhpredisClientFactory.php#L134
And here: https://github.com/snc/SncRedisBundle/blob/master/src/Factory/PredisParametersFactory.php#L49

But what I am not sure about and why I am creating this issue is to ask your opinion on how to provide this information in the snc bundle config.

So far I've come up with 2 ideas:

  1. Add an option in the config (Easy and quick to do)
snc_redis:
    clients:
        default:
            type: phpredis
            dsn: 'rediss://S3cR3t@127.0.0.1:6379'
            options:
                tls_version: 1.2
  1. Add the information in the DSN (Requires extra parsing and "hard" to understand but closer to what is done by the bundle)
snc_redis:
    clients:
        default:
            type: phpredis
            dsn: 'redissv1.2://S3cR3t@127.0.0.1:6379'

I'm gonna provide a MR for that, I just wanted your opinion first
On my side I think I'm leaning more towards the 2nd option as it's closer to the reality even if more complex

I've noticed this issue too: #604 which is kind of related without being related
The TLS version is not an SSL options but part of the URL itself

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImproves existing functionality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions