[英]WCF: Occasional rejection of client credentials
我們目前正在將舊 WCF 應用程序的服務遷移到新域中的服務器。 由於遷移,下面提到的錯誤不時發生。
發生了異常...
異常詳細信息:服務器拒絕了客戶端憑據。
System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]:服務器拒絕了客戶端憑據。 (Fault Detail 等於 An ExceptionDetail,可能由 IncludeExceptionDetailInFaults=true 創建,其值為:
System.ServiceModel.Security.SecurityNegotiationException:服務器拒絕了客戶端憑據。
System.Security.Authentication.InvalidCredentialException:服務器拒絕了客戶端憑據。
System.ComponentModel.Win32Exception: 登錄嘗試失敗 --- 內部 ExceptionDetail 堆棧跟蹤結束 ---
在 System.Net.Security.NegoState.ProcessReceivedBlob(Byte[] message, LazyAsyncResult lazyResult)
在 System.Net.Security.NegoState.StartSendBlob(Byte[] message, LazyAsyncResult lazyResult)
在 System.Net.Security.NegoState.StartSendBlob(Byte[] message, LazyAsyncResult lazyResult)
在 System.Net.Security.NegoState.ProcessAuthentication(LazyAsyncResult lazyResult)
在 System.Net.Security.NegotiateStream.AuthenticateAsClient(NetworkCredential credential, String targetName, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel)
在...)。
困難的是,所有呼叫都在 95% 的時間內有效,並且沒有明確的原因導致呼叫突然失敗。
配置和調用如下所示:
呼叫者:
<binding name="Binding_ServiceTCP"
closeTimeout="00:30:00" openTimeout="00:30:00"
receiveTimeout="infinite" sendTimeout="infinite"
transferMode="Buffered" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
<readerQuotas maxDepth="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"
maxStringContentLength="2147483647" />
</binding>
<Channel ChannelType="IWcfInterface" Name="ServiceName"
Binding="Binding_ServiceTCP" Address="net.tcp://serverinnewdomain:59886/Service" Identity="" />
objectOfIWcfInterfaceImplementingClass.WcfCall();
接受者:
<service behaviorConfiguration="BehaviourName" name="ServiceName">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="Binding_ServiceTCP" contract="IWcfInterface" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://serverinnewdomain:59886/Service" />
</baseAddresses>
</host>
</service>
<behavior name="BehaviourName">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
<binding name="Binding_ServiceTCP"
closeTimeout="00:30:00" openTimeout="00:30:00"
receiveTimeout="infinite" sendTimeout="infinite"
transferMode="Buffered" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
<readerQuotas maxDepth="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"
maxStringContentLength="2147483647" />
</binding>
[ServiceContract(Namespace = "http://some.cool/namespace")]
[XmlSerializerFormat]
public interface IWcfInterface
{
[OperationContract]
[XmlSerializerFormat(SupportFaults = true)]
SomeClass WcfCall();
}
該實現是通過城堡注冊的。
container.Register(Component.For<IWcfInterface>().ImplementedBy<WcfClass>().LifeStyle.PerWcfOperation());
在舊服務器上安裝 .NET 4.7,在新服務器上安裝 4.8。
我懷疑憑據在從呼叫者到接收者的途中丟失了,我聯系了網絡團隊,但他們告訴我這是不可能的。
我想查看哪些憑據到達服務。 如果這是不可能的,我也會滿足於任何其他解決方案。
這主要是由於 Windows 域不匹配造成的,有兩種解決方案:
將應用程序服務器和客戶端放在同一個 Windows 域中。
如果計算機在同一個域中,請驗證用於運行服務的用戶帳戶是域帳戶而不是本地服務器帳戶。
請注意,如果您使用 windows 身份驗證,則客戶端域和服務器必須在同一個 windows 域中。
另一種解決方案是不使用 Windows 身份驗證:
<bindings>
<netTcpBinding>
<binding name="TcpBinding">
<security mode="None"></security>
</binding>
</netTcpBinding>
</bindings>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.