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

本文介绍了如何解决跨域或Internet环境下使用Remoting遇到的身份验证问题。通过调整客户端和服务端配置,实现不同域间的Remoting服务调用。

[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配置信息

<system.runtime.remoting>

    <application>

      <client>

 

        <wellknown type="XXXX,YYYY"

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

 

      </client>

      <channels>

        <channel ref="tcp" secure="true"   

                    impersonationLevel="Impersonation" protectionLevel="EncryptAndSign"         

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

                    domain="RemotingServer-DomainName">

          <clientProviders>

            <formatter ref="binary"/>

          </clientProviders>

          <serverProviders>

            <formatter ref="soap" typeFilterLevel="Full" />

            <formatter ref="binary" typeFilterLevel="Full" />

          </serverProviders>

        </channel>

      </channels>

    </application>

  </system.runtime.remoting>

       用这样的配置就可以成功模拟服务器端的用户调用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)

 

转载于:https://www.cnblogs.com/zhengyun_ustc/archive/2006/06/09/remoting_InvalidCredentialException.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值