我正在使用几个 WCF 服务,所有服务均使用 WIF 和 STS 提供程序进行保护(均使用开箱即用的 Microsoft 代码和示例)。这些服务都是使用 .NET 3.5 构建的,并且最近全部更新到 .NET 4.0。ALL与服务相关的 .dll 也已更新至 4.0。这些服务多年来一直按原样运行,直到我更新框架版本。
现在的问题是,当调用由 STS WCF 服务保护的 WCF 服务时,在将令牌传递回调用由 STS 保护的 WCF 服务的客户端应用程序后,会生成错误:
从对方收到不安全或不正确安全的故障
派对。有关错误代码和详细信息,请参阅内部FaultException。
HResult -2146233087
{“处理安全令牌时发生错误
信息。”}
服务器堆栈跟踪:位于
System.ServiceModel.Channels.SecurityChannelFactory1.SecurityRequestChannel.ProcessReply(Message
reply, SecurityProtocolCorrelationState correlationState, TimeSpan
timeout) at
System.ServiceModel.Channels.SecurityChannelFactory
1.SecurityRequestChannel.Request(消息
消息,TimeSpan 超时)于
System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.DoOperation(SecuritySessionOperation
操作、EndpointAddress 目标、Uri via、SecurityToken
currentToken、TimeSpan 超时)位于
System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.GetTokenCore(TimeSpan
超时)在
System.IdentityModel.Selectors.SecurityTokenProvider.GetToken(TimeSpan
超时)在
System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.OnOpen(TimeSpan
超时)在
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
超时)在
System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan超时)
在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
超时)在
System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel
通道,TimeSpan 超时)
System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan
超时,CallOnceManager 级联)
System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan
超时)在 System.ServiceModel.Channels.ServiceChannel.Call(String
动作、布尔单向、ProxyOperationRuntime 操作、Object[] ins、
Object[] outs,TimeSpan 超时)位于
System.ServiceModel.Channels.ServiceChannel.Call(字符串操作,
Boolean oneway,ProxyOperationRuntime操作,Object[] ins,
对象[] outs) at
System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage
methodCall,ProxyOperationRuntime 操作)位于
System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage
信息)
在 [0] 处重新抛出异常:
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg、IMessage retMsg) at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData,Int32 类型)位于
MyProject.IMyService.GetInfo()
在 MyProject.Proxy.GetInfo() 中
c:\Projects\Proxy.cs:行
36
深入挖掘还表明:
无效的安全令牌作为 InnerException.Code.Subcode.Name 属性值。
因此,我查看了以下内容,这些内容都表明系统上的时钟存在问题,但没有一个起作用:
http://blogs.msdn.com/b/dhrubach/archive/2009/12/14/9936037.aspx http://blogs.msdn.com/b/dhrubach/archive/2009/12/14/9936037.aspx
从另一方收到不安全或不正确的安全故障。(使用 SAML 时) https://stackoverflow.com/questions/14688561/an-unsecured-or-incorrectly-secured-fault-was-received-from-the-other-party-whe
http://blogs.msdn.com/b/xiaowen/archive/2009/03/26/tip-add-a-clock-skew-to-prevent-some-security-faults.aspx?Redirected=true http://blogs.msdn.com/b/xiaowen/archive/2009/03/26/tip-add-a-clock-skew-to-prevent-some-security-faults.aspx?Redirected=true
我已附加到这些服务中的调试器并尝试遍历代码,但我找不到罪魁祸首。有谁知道我可能哪里出了问题?
EDIT:有趣的是toughSTS 服务中 WIF 的一部分进行身份验证works!我已打开日志记录并捕获以下内容:
Service authorization succeeded.
Service: http:// localhost:4068 /MyID/MyID.svc
Action: http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue
ClientIdentity: Domain\allen; S-1-5-21-1234567890-1234567895-0987654321-45678
AuthorizationContext: uuid-22fad22a-22fe-123c-9b69-a22c23f569ce-99
ActivityId: <null>
ServiceAuthorizationManager: <default>
我还打开了 WCF 日志记录.config
查看 .svc 文件,它们没有产生任何指出问题的错误信息。就像 STS 说的:“嘿,您已通过身份验证,我们通过了您并生成了令牌,现在我们就完成了!”看来调用客户端不喜欢该令牌。然而,这已经工作了很长时间,直到我更改了框架版本。据我所知,从 3.5 到 4.0,WIF 没有任何重大变化,但最大的变化是在 4.5 中,WIF 集成到了框架中。
So all授权有效,只是客户端接受令牌存在问题?