WCF NetTcpBinding 何时需要完全信任客户端? [英] When does WCF NetTcpBinding need full trust on the client?

查看:27
本文介绍了WCF NetTcpBinding 何时需要完全信任客户端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 WCF 与多个服务器进行通信.

I'm using WCF to communicate to several servers.

对于我的本地服务器 netTcpBinding 工作正常,没有问题.

For my local server netTcpBinding works like expected, no problems.

但是当我尝试使用 app.config 中的以下 netTcpBinding 连接到我的远程服务器 (Azure) 时,这将使应用程序在初始化时崩溃,因为在没有完全信任的情况下无法创建 netTcpBinding.

But when I try to connect to my remote server (Azure) using the following netTcpBinding in app.config, this will crash the application on initialization since the netTcpBinding can't be created without full trust.

app.config 文件中的这个绑定,

<bindings>
  <netTcpBinding>
    <binding name="NetTcpBinding_IService" closeTimeout="00:01:00"
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
      transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
      hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288"
      maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00"
        enabled="false" />
      <security mode="Transport">
        <transport clientCredentialType="None" protectionLevel="EncryptAndSign" />
        <message clientCredentialType="Windows" />
      </security>
    </binding>
  </netTcpBinding>
</bindings>

会导致这个错误:

为system.serviceModel/bindings"创建配置节处理程序时出错:该程序集不允许部分受信任的调用者.(K:\Somepath\Testing.exe.Config 第 6 行)

An error occurred creating the configuration section handler for "system.serviceModel/bindings": That assembly does not allow partially trusted callers. (K:\Somepath\Testing.exe.Config line 6)

奇怪的事情:在 app.config 文件中,我让客户端端点连接到其他 netTcpBindings(没有在绑定部分明确声明它们).

The strange thing: In the app.config file I got client endpoints connecting to other netTcpBindings (without declaring them explizitely in the binding section).

为什么这些通用的 netTcpBindings 可以在部分信任的情况下工作,而我上面展示的却没有?

Why do these generic netTcpBindings work in partial trust, but the one I showed above does not?

或者我只是被这个错误消息弄糊涂了,问题不在于完全信任?

Or am I just confused by this error message and the problem is not about full trust?

更新:如果我删除 <binding> 部分,这些东西将毫无问题地运行.所以我可以在部分信任的情况下使用netTcpBinding,但我不允许修改参数?很遗憾,因为我想对我的通信进行某种形式的加密.

Update: If I remove the <binding> section the stuff will run without problems. So I'm allowed to use netTcpBinding in partial trust, but I'm not allowed to modify the parameters? This is a pity since I'd like to have some form of encryption on my communication.

推荐答案

NetTcpBinding 通常在部分信任环境中不受支持.

NetTcpBinding in general is not supported in partial trust environments.

虽然基本通信工作正常(正如您在其他环境中所见),但诸如 TransportSecurity 和 ReliableMessaging(您在示例配置中具有)等功能明确不支持部分信任(这很糟糕,很重要).

While the basic communication works fine (as you've seen in other environments), features like TransportSecurity and ReliableMessaging (which you have on your sample configuration) are explicitly not supported on partial trust (it sucks, big time).

这篇关于WCF NetTcpBinding 何时需要完全信任客户端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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