【发布时间】:2014-04-16 09:42:07
【问题描述】:
我有一个使用 NetTcpBinding 实现的 WCF 服务。它可以通过互联网消费。虽然它不在我的域中运行,但我无法使用 Windows 凭据。我现在正在寻找一种方法来保护服务。
没有安全性的方法可以正常工作。但是对于实时系统而言,安全性是必需的。因此,我阅读了很多内容,展示了如何配置 wsHttpBindings 之类的 http://msdn.microsoft.com/en-us/library/ms729789.aspx。但这并没有说明如何配置 NetTcpBinding。
我现在知道默认情况下 NetTcpBinding 是安全的(请参阅 http://www.codemag.com/article/0611051)。但它在适合我的配置中仍然安全吗?
服务:
<netTcpBinding>
<binding name="tcpBinding"
maxBufferSize="67108864"
maxReceivedMessageSize="67108864"
maxBufferPoolSize="67108864"
transferMode="Buffered"
closeTimeout="00:02:00"
openTimeout="00:02:00"
receiveTimeout="00:20:00"
sendTimeout="00:02:00"
maxConnections="100">
<security mode="None">
</security>
<readerQuotas maxArrayLength="67108864"
maxBytesPerRead="67108864"
maxStringContentLength="67108864"/>
<reliableSession enabled="true" inactivityTimeout="24:00:00"/>
</binding>
</netTcpBinding>
客户:
<binding name="NetTcpBinding_IMessageSending">
<reliableSession inactivityTimeout="00:20:00" enabled="true" />
<security mode="None"></security>
</binding>
我也知道我可以使用证书以某种方式保护服务。但实际上这对我不起作用。我为服务配置了这样的行为:
<behavior name="tcpBehavior">
<serviceMetadata httpGetEnabled="false" httpGetUrl=""/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceThrottling maxConcurrentCalls="100" maxConcurrentSessions="100"/>
<serviceCredentials>
<serviceCertificate findValue="GeoTrust SSL CA - G2" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
</serviceCredentials>
</behavior>
绑定看起来像这样:
<binding name="tcpBinding"
maxBufferSize="67108864"
maxReceivedMessageSize="67108864"
maxBufferPoolSize="67108864"
transferMode="Buffered"
closeTimeout="00:02:00"
openTimeout="00:02:00"
receiveTimeout="00:20:00"
sendTimeout="00:02:00"
maxConnections="100">
<security mode="Transport" />
<readerQuotas maxArrayLength="67108864"
maxBytesPerRead="67108864"
maxStringContentLength="67108864"/>
<reliableSession enabled="true" inactivityTimeout="24:00:00"/>
</binding>
和这样的端点:
<service name="MessageSendingService" behaviorConfiguration="tcpBehavior" >
<endpoint address="" binding="netTcpBinding" bindingConfiguration="tcpBinding"
contract="IMessageSending" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
实际上,我真的不知道如何配置客户端来使用它。
我的(不工作的)客户端配置:
<binding name="NetTcpBinding_IMessageSending">
<reliableSession inactivityTimeout="00:20:00" enabled="true" />
<security mode="Transport">
</security>
</binding>
还是我的配置有错误?
事实上,服务请求失败并出现 SecurityNegotiationException。有谁可以告诉我如何配置具有匿名客户端的传输或消息安全的 NetTcpBinding 服务?
提前致谢。
【问题讨论】:
标签: .net web-services wcf security nettcpbinding