使用STS和WCF遇到不安全或错误安全的故障异常问题

 婉婷雅铃43 发布于 2023-02-12 20:17

我正在使用WIF和STS提供商(所有使用开箱即用的Microsoft代码和示例)保护的几个WCF服务.这些服务都是使用.NET 3.5构建的,并且最近都已更新到.NET 4.0.与服务关联的所有 .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(消息消息,时间跨度超时)在System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.DoOperation(SecuritySessionOperation操作,目标的EndpointAddress,经由开放的,SecurityToken currentToken,时间跨度超时) System.ServiceModel处的System.ServiceModel.SecuritySessionSecurityTokenProvider.GetTokenCore(TimeSpan超时)处于System.ServiceModel.Security上的System.ServiceModel.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.OnOpen(TimeSpan timeout)的System.IdentityModel.Selectors.SecurityTokenProvider.GetToken(TimeSpan超时) .Channels.CommunicationObject.Open(时间跨度超时)在System.ServiceModel.Channels.ServiceChannel.OnOpen(时间跨度超时)
在System.ServiceModel.Channels.CommunicationObject.Open(时间跨度超时)在System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System .ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel chan NEL,时间跨度超时)在System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(时间跨度超时,CallOnceManager级联)在System.ServiceModel.Channels.ServiceChannel.EnsureOpened(时间跨度超时)在System.ServiceModel.Channels.ServiceChannel.Call(字符串动作,布尔单向,ProxyOperationRuntime操作,对象[]项,在System.ServiceModel.Channels.ServiceChannel.Call(字符串动作,布尔单向,ProxyOperationRuntime操作对象[]奏,时间跨度超时),对象[]项,对象[]奏)在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage包括methodCall,ProxyOperationRuntime操作)在System.ServiceModel.Channels.ServiceChannelProxy.Invoke(即时聊天消息)

在异常重新抛出[0]:在System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(即时聊天reqMsg,即时聊天retMsg)处MyProject.IMyService System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&MSGDATA,的Int32类型). GetInfo()位于c:\ Projects\Proxy.cs中的MyProject.Proxy.GetInfo():第36行

深入挖掘也表明:

InvalidSecurityToken作为InnerException.Code.Subcode.Name属性值.

所以我看了下面的内容,这些都暗示了系统上的时钟问题,但没有一个有效:

http://blogs.msdn.com/b/dhrubach/archive/2009/12/14/9936037.aspx
从另一方收到了一份不安全或不正确安全的故障.(使用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:   
ServiceAuthorizationManager: 

我还打开了WCF日志记录.config来查看.svc文件,并且它们没有产生任何错误信息,指出了问题.这就像STS说:"嘿,你经过身份验证,我们通过你并生成令牌,现在我们已经完成了!" 看来调用客户端不喜欢令牌.然而,这已经成功了,直到我改变了框架版本.根据我的知识,从3.5 - > 4.0没有任何重大的WIF变化,而是在4.5中将WIF集成到框架中的重大变化.

因此,所有授权都有效,只是客户端认为令牌被接受存在问题?

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有