我已经设置了一个WCF服务,该服务旨在在Kerberos下运行。我遇到的问题是,每当我从服务向客户端抛出异常时,它似乎都会对异常详细信息发出单独请求,并且在时失败。对于相互身份验证的要求未得到满足远程服务器。'。
好消息 - 服务不会抛出异常的请求也能正常工作。
我目前的后备是允许NTLM,我想删除。我想了解问题的核心,试图克服'Kerberos总是很难'的心态。
基本网络详情:
尝试了异常类型:
FaultException,(虽然我不需要自定义异常,但它可能适用于此目的)+将以下内容添加到每个Web服务方法中:
[FaultContract(typeof运算(FaultException异常))]
设置ClientCredential :(客户端)
credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
credentials.Windows.AllowNtlm = false; // Set to true to allow it to work;
credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation;
以前问题的其他修正:
SpnEndpointIdentity 设置,感谢this question
SpnEndpointIdentity spnEndpointIdentity = new SpnEndpointIdentity("");
var address = new EndpointAddress(EndpointName, spnEndpointIdentity)
停止 407代理错误:
BasicHttpBinding.UseDefaultWebProxy = false;
客户收到的异常:(缩写堆栈跟踪)
(似乎表明 ProcessGetResponseWebException 调用正在尝试检索异常细节)
System.ServiceModel.CommunicationException was unhandled
Message=An error (The request was canceled) occurred while transmitting data over the HTTP channel.
StackTrace:
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Project.IMetadataManagement.GetMetadata(String identifier)
InnerException: System.Net.WebException
InnerException: System.Net.ProtocolViolationException
Message=The requirement for mutual authentication was not met by the remote server.
在网络配置中:
includeExceptionDetailInFaults 为真
<behavior name="Project.MetadataBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
绑定:
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpointBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
Windows身份验证设置
<system.webServer>
<security>
<authentication>
<windowsAuthentication enabled="true" useKernelMode="true" useAppPoolCredentials="true" >
<providers>
<clear />
<add value="Negotiate" />
<add value="NTLM" />
</providers>
<extendedProtection tokenChecking="None" />
</windowsAuthentication>
<anonymousAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
服务示例
<services>
<service behaviorConfiguration="Project.MetadataBehavior" name="Project.MetadataManagement">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpEndpointBinding" contract="Project.IMetadataManagement">
</endpoint>
</service>
任何和所有帮助表示赞赏。我已经清空了实际的项目命名空间,所以希望我没有留下任何笨拙的错位。
感谢。