azure - 将最低 TLS 版本更改为 1.2 后无法连接到 Azure Redis

标签 azure redis

在我的 .NET Framework 4.6.1 应用程序中,我使用 StackExchange.Redis.StrongName 1.2.6 连接到 Azure Redis。 这是代码

    public RedisContext(string connectionString = null)
    {
        if (connectionString == null) return;

        Lazy<ConfigurationOptions> lazyConfiguration
            = new Lazy<ConfigurationOptions>(() => ConfigurationOptions.Parse(connectionString));

        var configuration = lazyConfiguration.Value;
        configuration.SslProtocols = SslProtocols.Tls12;//just added
        configuration.AbortOnConnectFail = false;

        Lazy<ConnectionMultiplexer> lazyConnection =
            new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect(configuration));
        _connectionMultiplexer = lazyConnection.Value;

        LogProvider.IsDisabled = true;

        var connectionEndpoints = _connectionMultiplexer.GetEndPoints();
        _lockFactory = new RedisLockFactory(connectionEndpoints.Select(endpoint => new RedisLockEndPoint
        {
            EndPoint = endpoint,
            Password = configuration.Password,
            Ssl = configuration.Ssl
        }));
    }

在 Azure 中,我已将 Redis 资源更改为使用 TLS1.2,并在代码中添加了这一行:

configuration.SslProtocols = SslProtocols.Tls12;//刚刚添加

现在,一切都不起作用了。这是我在 Application Insights 中遇到的错误:

连接到 Redis 时出错。无法连接到 Redis 服务器;连接超时

我还尝试将“,ssl=True,sslprotocols=tls12”添加到redis连接字符串中,但结果相同。

最佳答案

尝试引用 StackExchange.Redis 而不是 StackExchange.Redis.StrongName。我已经在我的一些项目中做到了这一点,现在它可以工作了。然而,一些第三方仍然使用 StrongName 而不是普通的 redis。 StackExchange.Redis.StrongName 现已弃用。 https://github.com/Azure/aspnet-redis-providers/issues/107 。我假设您尝试连接到 Azure Redis 与它们停止 TLS 1.0 和 1.1 支持有关?

关于azure - 将最低 TLS 版本更改为 1.2 后无法连接到 Azure Redis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60113048/

相关文章:

azure - 如何在 Azure 表存储中进行自由文本搜索?

Azure DevOps 自定义扩展图标丢失

c# - 禁用测试网络作业

python - celery 恢复从队列中消费

node.js - 每个用户的套接字 io channel 通知

azure - 如何将现有 AKS 添加到 AAD?

azure - 在 Azure Functions 中使用 F#

function - return_of_invalid_type 返回类型 'String' 不是方法 'void' 定义的 'getData'

java - 如何在java中为应用程序锁定redis集群

linux - 这些redis启动命令有什么区别