.NET客户端和服务器之间SignalR安全连接 [英] SignalR Secure Connection Between .NET Client and The Server

查看:179
本文介绍了.NET客户端和服务器之间SignalR安全连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在SignalR .NET,我们建立了一个连接,下面的客户端和服务器之间:

On SignalR .NET, we establish a connection as below between the client and server:

var connection = new HubConnection("http://mysite/");

接下来,我们订阅的事件,并开始下面的连接:

Next, we subscribe the events and start the connection as below:

connection.Start().Wait();

如果我想建立在客户端和服务器之间的安全连接。我们如何能够做到这一点与当前的特点是什么?

What if I would like to establish a secure connection between the client and server. How can we achieve that with current features?

我注意到,有 System.Net.ICredentials HubConnection 类的属性类型。这是此方式?如果是这样,我们应该如何处理验证在服务器端为我们的集线器?

I noticed that there is a property type of System.Net.ICredentials on HubConnection class. Is this the way for this? If so, how should we handle the Auth at the server side for our Hubs?

推荐答案

下面是我有我的设置:

  var hubConnection = new HubConnection("http://siteurl");
  hubConnection.Credentials = CredentialCache.DefaultNetworkCredentials;
  hubProxy = hubConnection.CreateProxy("My.Hub.Namespace");

  hubConnection.Start().Wait();

您当然可以传递不同的凭据,我使用<一个href=\"http://msdn.microsoft.com/en-us/library/system.net.credentialcache.defaultnetworkcredentials.aspx\">DefaultNetworkCredentials

You could of course pass in different credentials, I use DefaultNetworkCredentials

由DefaultNetworkCredentials返回的凭据重新presents在其中运行应用程序的当前安全上下文中的身份验证凭据。对于客户端应用程序,这些通常是运行应用程序的用户的Windows凭证(用户名,密码和域)。对于ASP.NET应用程序,默认网络凭据是登录用户的用户凭证,或者用户正在模拟。

The credentials returned by DefaultNetworkCredentials represents the authentication credentials for the current security context in which the application is running. For a client-side application, these are usually the Windows credentials (user name, password, and domain) of the user running the application. For ASP.NET applications, the default network credentials are the user credentials of the logged-in user, or the user being impersonated.

这篇关于.NET客户端和服务器之间SignalR安全连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆