跨域或者Internet访问Remoting[Remoting FAQ]

来源:互联网 发布:手机录音制作软件 编辑:程序博客网 时间:2024/04/30 19:35

[Remoting FAQ]

跨域或者Internet访问Remoting

Version

Date

Creator

Description

1.0.0.1

2006-6-1

郑昀@Ultrapower

草稿

 

继续阅读之前,我们假设您熟悉以下知识:

n         Remoting

[需求]

虽然说,Remoting一般都在同一个域内调用,但有时候,也需要跨域访问,甚至于跨Internet访问。毕竟,让第三方远程测试下Remoting方法,不能要求人家加入你的域。

[现象]

在走TCP Channel访问Remoting情况下。

如果双方未作特殊处理,那么客户端会得到如下异常,提示对方Remoting服务不能信任你的身份:

异常信息

Unhandled Exception:

System.Security.Authentication.InvalidCredentialException:
The server has rejected the client credentials.

---> System.ComponentModel.Win32Exception: 登录没有成功

[分析]

在《RemotingFX2.0中的新特性》提到了这么一段话:

By default, a TCP client channel authenticates itself with the user identity under which the client process is running. You can specify an alternative identity by setting the useDefaultCredentials configuration property to false and setting the domain, username, and password configuration properties to specify an alternative identity.

默认情况下,一个TCP客户通道以当前运行的客户进程之下的用户标识来验证。也可以通过把useDefaultCredentials 配置属性设为false 并且设置domain, username, and password configuration 配置属性来设置特定的自定义标识。

 

[解决]

有人说,可以在服务端在注册Channel时,这么做:

将原来的ChannelServices.RegisterChannel(chan1, true);

改为

ChannelServices.RegisterChannel(chan1, false);

如果是这样声明的:

RemotingConfiguration.Configure(filename, true);

改为

RemotingConfiguration.Configure(filename, false);

这样来允许另外一个域的机器访问。

       但是似乎没有作用。

 

       下面这种做法,就不需要服务器端作改动。客户端调用时,需要知道服务器端的一个普通用户帐号密码,来配置自己的remoting

先看

客户端的Remoting配置信息

   

     

 

       

                   url="tcp://RemotingServer:Port/Demo"/>

 

     

     

        secure="true"   

                    impersonationLevel="Impersonation" protectionLevel="EncryptAndSign"         

                    username="RemotingServer-UserName" password="PASSWORD"         

                    domain="RemotingServer-DomainName">

         

           

         

         

           

           

         

       

     

   

 

       用这样的配置就可以成功模拟服务器端的用户调用Remoting

 

      

[更多信息]

对于上面的配置信息,我们需要说明几个特别的节点:

Client-Settings

  • secure
    true/false: enables/disables security
  • username, password, domain
    if you don’t want to use the credentials of the client process, you can specify explicit ones here
  • impersonationLevel
    Identification: The server can use the client token only for identity information and role based checks
    Impersonation: The server can impersonate the client token to access server-local resources
    Delegation: The server can delegate the client credentials
  • protectionLevel
    None: clear text
    Encrypt/Sign: self explanatory
    EncryptAndSign: recommended setting
  • servicePrincipalName
    SPN of the server. Required for Kerberos. Can use SPN (service/domain) or account syntax (domain/service)

 




原创粉丝点击