【发布时间】:2013-12-18 00:01:15
【问题描述】:
我正在处理几个使用 WIF 和 STS 提供程序保护的 WCF 服务(全部使用开箱即用的 Microsoft 代码和示例)。这些服务都是使用 .NET 3.5 构建的,并且最近都更新到了 .NET 4.0。 ALL 与服务相关的 .dll 也已更新到 4.0。这些服务多年来一直按原样工作,直到我更新了框架版本。
现在的问题是,当调用由 STS WCF 服务保护的 WCF 服务时,在将令牌传递回调用由 STS 保护的 WCF 服务的客户端应用程序后会生成错误:
从对方收到不安全或不正确安全的故障 派对。故障代码和细节见内部FaultException。
HResult -2146233087
{"处理安全令牌时发生错误 消息。”}
服务器堆栈跟踪:在 System.ServiceModel.Channels.SecurityChannelFactory
1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout) at System.ServiceModel.Channels.SecurityChannelFactory1.SecurityRequestChannel.Request(消息 消息,TimeSpan 超时)在 System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.DoOperation(SecuritySessionOperation 操作、EndpointAddress 目标、Uri via、SecurityToken currentToken,TimeSpan 超时)在 System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.GetTokenCore(时间跨度 超时)在 System.IdentityModel.Selectors.SecurityTokenProvider.GetToken(时间跨度 超时)在 System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.OnOpen(TimeSpan 超时)在 System.ServiceModel.Channels.CommunicationObject.Open(时间跨度 超时)在 System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan 超时)
在 System.ServiceModel.Channels.CommunicationObject.Open(时间跨度 超时)在 System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel 通道,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(时间跨度 超时,CallOnceManager 级联)在 System.ServiceModel.Channels.ServiceChannel.EnsureOpened(时间跨度 超时)在 System.ServiceModel.Channels.ServiceChannel.Call(字符串 action, Boolean oneway, ProxyOperationRuntime 操作, Object[] ins, Object[] 出局,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannel.Call(字符串动作, Boolean oneway, ProxyOperationRuntime 操作, Object[] ins, 对象 [] 出局)在 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)在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(消息数据& msgData,Int32 类型)在 MyProject.IMyService.GetInfo() 在 MyProject.Proxy.GetInfo() 中 c:\Projects\Proxy.cs:行 36
深入挖掘它也表明:
InvalidSecurityToken 作为 InnerException.Code.Subcode.Name 属性值。
所以我查看了以下内容,这些都表明系统上的时钟存在问题,但没有一个有效:
http://blogs.msdn.com/b/dhrubach/archive/2009/12/14/9936037.aspx
An unsecured or incorrectly secured fault was received from the other party.(When working with SAML )
http://blogs.msdn.com/b/xiaowen/archive/2009/03/26/tip-add-a-clock-skew-to-prevent-some-security-faults.aspx?Redirected=true
我已附加到这些服务中的调试器并尝试遍历代码,但找不到罪魁祸首。有谁知道我可能对此有什么不妥?
编辑: 有趣的是在 STS 服务中 WIF 的 困难 部分进行身份验证有效! 我已打开日志记录并捕获以下内容:
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>
我还在.config 中打开了 WCF 日志记录以查看 .svc 文件,但它们没有产生任何指出问题的错误信息。就像 STS 说:“嘿,您已通过身份验证,我们通过了您并生成了令牌,现在我们完成了!”似乎调用客户端不喜欢令牌。然而,这一直有效,直到我更改了框架版本。据我所知,从 3.5 -> 4.0 开始,WIF 没有任何重大变化,但主要的变化是在 4.5 中 WIF 被集成到框架中。
所以所有的授权都有效,只是我认为客户端接受令牌存在问题?
【问题讨论】:
-
我看到这个问题有 1 个赞成票和 1 个反对票。请提供反馈,以便在否决时可以改进问题。我试图提供尽可能多的信息。
-
您并没有真正提供太多,请显示代码您在代码和 web.config 中的安全设置。我可以从异常堆栈中看到,在 WCF 端处理安全令牌期间出现了问题。
-
只是一个想法,但您可以尝试在 ssl 端点上公开客户端吗?
标签: wcf wif sts-securitytokenservice