【问题标题】:SignalR Scaleout with Redis - No SSL SupportSignalR Scaleout 与 Redis - 不支持 SSL
【发布时间】:2015-01-06 16:24:41
【问题描述】:

我已将 nuget 包 Microsoft.AspNet.SignalR.Redis 添加到我的项目中,以允许我按照以下说明使用 redis 缓存背板扩展我的 signalR 应用程序:

http://www.asp.net/signalr/overview/performance/scaleout-with-redis

我已经在 Azure 上设置了一个 redis 缓存服务器,并且使用与端口 6379 的非安全连接一切正常。

我现在想启用 SSL 以增加安全性,但似乎不支持使用 nuget 插件进行 SSL 连接:

如果我尝试使用安全端口 6380,nuget 包似乎不支持 SSL 连接。

例子:

GlobalHost.DependencyResolver.UseRedis("redis-server.cloudapp.net", 6380,
"Password/Key", "ChatApp")

这些不是启用 SSL 的开关

这是连接的完整代码:

public class Startup
{
    public void Configuration(IAppBuilder app)
    {

        // Configuration for scale out using Redis:
        var redisEnabled = Convert.ToBoolean(WebConfigurationManager.AppSettings["RedisScaleOut_Enable"]);
        if (redisEnabled)
        {
            var redisHost = WebConfigurationManager.AppSettings["RedisScaleOut_Host"];
            var redisPort = Convert.ToInt16(WebConfigurationManager.AppSettings["RedisScaleOut_Port"]);
            var redisPassword = WebConfigurationManager.AppSettings["RedisScaleOut_Password"];
            var redisAppName = WebConfigurationManager.AppSettings["RedisScaleOut_AppName"];

            GlobalHost.DependencyResolver.UseRedis(redisHost, redisPort, redisPassword, redisAppName);
        }

        // Branch the pipeline here for requests that start with "/signalr"
        app.Map("/signalr", map =>
        {
            // Setup the CORS middleware to run before SignalR.
            // By default this will allow all origins. You can 
            // configure the set of origins and/or http verbs by
            // providing a cors options with a different policy.
            map.UseCors(CorsOptions.AllowAll);

            var hubConfiguration = new HubConfiguration
            {
                // You can enable JSONP by uncommenting line below.
                // JSONP requests are insecure but some older browsers (and some
                // versions of IE) require JSONP to work cross domain
                EnableJSONP = true
            };

            // Run the SignalR pipeline. We're not using MapSignalR
            // since this branch already runs under the "/signalr"
            // path.
            map.RunSignalR(hubConfiguration);
        });

    }
}

【问题讨论】:

    标签: c# asp.net azure signalr


    【解决方案1】:

    最新版本的 SignalR(当前为 2.2.1)允许 SSL:

    var connectionString = "myredis.redis.cache.windows.net:6380,password=myPassword,ssl=True,abortConnect=False";
    
    GlobalHost.DependencyResolver.UseRedis(new RedisScaleoutConfiguration(connectionString, "YourServer"));
    

    感谢 Michael Parshin 在这里的回答:https://stackoverflow.com/a/29591328/648738

    【讨论】:

      【解决方案2】:

      SignalR Redis 背板目前正在使用 Booksleeve,据我所知here 他们正在使用裸套接字连接到 Redis。我不了解 Redis,但我认为通信不是基于 HTTP 而只是 TCP,所以你不能直接使用 SSL。

      【讨论】:

      • 数据加密支持 Redis 不支持加密。为了实现受信任方可以通过 Internet 或其他不受信任的网络访问 Redis 实例的设置,应实施额外的保护层,例如 SSL 代理。 Redis Security
      • StackExchange.Redis 缓存客户端和 Microsoft.RedisSessionStateProvider 都支持 SSL。他们必须已经实现了自己的代理或使用 https 进行通信。
      • SignalR 2.2.0 将使用 StackExchange.Redis 而不是 Booksleeve。
      • 并澄清 StackExchange.Redis(截至目前 1.0.481)确实支持 SSL。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-05
      • 2020-01-12
      • 2021-10-31
      • 2013-04-06
      • 2015-06-16
      • 2017-06-05
      相关资源
      最近更新 更多