1
votes

I have added the nuget package Microsoft.AspNet.SignalR.Redis to my project to allow me to scale out my signalR application using the redis cache backplane following instructions at:

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

I have setup a redis cache server on Azure and everything is working perfectly using a non-secure connection to port 6379.

I now want to enable SSL for added security but there doesn't seem to be any support for SSL connections using the nuget plugin:

If I try using the secure port 6380, the nuget package doesn't seem to support SSL connections.

Example:

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

These is no switch to enable SSL

Here is the full code to connect:

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);
        });

    }
}
2

2 Answers

3
votes

The latest version of SignalR (currently 2.2.1) allows for SSL like so:

var connectionString = "myredis.redis.cache.windows.net:6380,password=myPassword,ssl=True,abortConnect=False";

GlobalHost.DependencyResolver.UseRedis(new RedisScaleoutConfiguration(connectionString, "YourServer"));

Thanks to Michael Parshin for his answer here: https://stackoverflow.com/a/29591328/648738

1
votes

SignalR Redis backplane is currently using Booksleeve and from what I can see here they are connecting to Redis using bare sockets. I don't know Redis but I assume the communication is not HTTP based but just TCP so you cannot use SSL directly.