CacheManager icon indicating copy to clipboard operation
CacheManager copied to clipboard

Redis sslprotocols=tls12 support

Open code-junky opened this issue 5 years ago • 2 comments

Azure Redis has deprecated TLS 1.0 and 1.1 and will retire these protocols in the near future. According to Microsoft, StackExchange.Redis users need to add sslprotocols=tls12 to their connection string to support TLS 1.2.

Unfortunately, this doesn't seem to work for CacheManager. When adding this option to our connection string, it throws back an error with the same connection string but excludes this option. It seems like CacheManager reconstructs the string internally and doesn't support this particular option.

Here's the code we use to create the CacheManager instance:

CacheFactory.Build<string>(settings =>
	settings.WithUpdateMode(CacheUpdateMode.Up)
		.WithRedisConfiguration("redis", connectionString, redisDatabaseId)
		.WithRedisCacheHandle("redis", false)
);

Here's the redis connection string: myrediscacheurl.net:6380,password=myredisaccesskey,ssl=True,abortConnect=False,sslprotocols=tls12

Here's the error we're getting: Connection to 'myrediscacheurl.net:6380,password=****,ssl=True,abortConnect=False' failed.

Notice that the error excludes the sslprotocols=tls12 portion of the connection string? Has anyone else encountered this? Is there a known fix?

code-junky avatar Jul 30 '20 00:07 code-junky

Yeah that looks like something I'd have to add to the configuration part of the Redis client.

The only work around right now would be to initializing the multiplexer yourself and pass the instance to CacheManager (there is an option to do that)

MichaCo avatar Jul 30 '20 10:07 MichaCo

Redis .NET clients use the earliest TLS version by default on .NET Framework 4.5.2 or earlier, and use the latest TLS version on .NET Framework 4.6 or later. If you're using an older version of .NET Framework, you can enable TLS 1.2 manually

[source]

So I guess if you are using .NET 4.6 and above it should work without changing the connection string

jkatsiotis avatar Nov 02 '20 21:11 jkatsiotis