我有一个WCF服务,必须使用Windows和证书身份验证进行保护。 我知道wsHttpBinding不支持流式传输,但是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')
提供
答案 0 :(得分:1)
这不是一步完成,而是两个步骤。
使用证书身份验证启用传输安全性。
使用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和AsymmetricSecurityBindingElement
。 TransportSecurityBindingElement
用于提供混合模式安全性。当消息层提供安全性时,将使用其他两个元素。
提供传输级别安全性时使用其他类:
HttpsTransportBindingElement
SslStreamSecurityBindingElement
WindowsStreamSecurityBindingElement
您可以获得以下帮助:
How to: Create a Custom Binding Using the SecurityBindingElement
和
答案 1 :(得分:0)
这对我有用:
<basicHttpBinding>
<binding name="basic" transferMode="Streamed" messageEncoding="Mtom">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" />
</security>
</binding>
</basicHttpBinding>