【问题标题】:WCF Streaming with authentication带有身份验证的 WCF 流式处理
【发布时间】:2014-07-23 13:04:16
【问题描述】:

我有一个 WCF 服务,它必须通过 Windows 和证书身份验证进行保护。 我知道 wsHttpBinding 不支持 Streaming 但according to msdn 它可以使用传输安全和 customBinding 来完成,但我无法做到......

<customBinding>
    <binding name="AuthBinding">
      <mtomMessageEncoding maxBufferSize="65535" />
      <windowsStreamSecurity protectionLevel="Sign"/>
      <httpTransport transferMode="Streamed" maxReceivedMessageSize="2147483647" />
    </binding>
</customBinding>

我要从一个例外转到另一个:

绑定“System.ServiceModel.Channels.CustomBinding”的安全功能与生成的运行时对象的不匹配。这很可能意味着绑定包含 StreamSecurityBindingElement,但缺少支持 Stream Security 的 TransportBindingElement

或者

请求消息必须受到保护。这是合约操作('IEntity'、'WebService.Entity')所要求的。保护必须由绑定提供('CustomBinding','WebService.Entity')

【问题讨论】:

  • 您面临的实际问题是什么?

标签: c# wcf authentication streaming


【解决方案1】:

这不是一步完成,而是两步。

  1. 通过证书身份验证启用传输安全性。

  2. 使用 Windows 身份验证启用传输安全性。

我也不确定两者可以一起工作。

但发现的 MSDN 文章似乎指向了正确的方向:

How to: Secure a Service with Windows Credentials with wsHttpBinding

请参考 MSDN 中的这些链接以进行进一步学习(如果您急于交付一些里程碑,帮助不大):

Transport Security with Windows Authentication

Transport Security with Certificate Authentication


更新

您必须使用具有混合(使用消息凭据传输)安全模式的自定义绑定。

三个绑定元素与消息级别的安全性相关,它们都派生自SecurityBindingElement 类。

这三个是TransportSecurityBindingElement、SymmetricSecurityBindingElement 和AsymmetricSecurityBindingElementTransportSecurityBindingElement 用于提供混合模式安全。当消息层提供安全性时,使用其他两个元素。 提供传输级安全性时使用其他类:

HttpsTransportBindingElement  
SslStreamSecurityBindingElement 
WindowsStreamSecurityBindingElement

您可以获得以下帮助:

How to: Create a Custom Binding Using the SecurityBindingElement

Security Capabilities with Custom Bindings

【讨论】:

  • wsHttpBinding 不允许使用 Streaming,我必须使用 customBinding,但这很棘手
  • 是的,如果你是第一次做的话,这很棘手,而且很花时间。
【解决方案2】:

这对我有用:

<basicHttpBinding>
    <binding name="basic"  transferMode="Streamed" messageEncoding="Mtom">
        <security mode="TransportWithMessageCredential">
            <message clientCredentialType="UserName" />
        </security>
    </binding>
</basicHttpBinding>

【讨论】:

    猜你喜欢
    • 2012-01-25
    • 2011-06-08
    • 2014-07-27
    • 2014-06-30
    • 1970-01-01
    • 2010-12-13
    • 1970-01-01
    • 1970-01-01
    • 2018-06-26
    相关资源
    最近更新 更多