2010-02-22 65 views
1

我在Windows Server 2008上使用IIS 7.5托管我的Web应用程序, 我有2个Web应用程序: 1.第一个是核心sso(Single Sign-on)服务与登录页面。 2.另一个Web应用程序托管在使用第一个应用程序的同一个Web服务器上。WIF RTM发生奇怪的错误,在复位后发生IIS

我使用WIF RTM来实现SSO,

通常,这是没有任何问题运行良好,用户可以登录扔SSO和重定向回起始页。 但是当我首先登录扔SSO,然后重新启动IIS,如果我回来的第二个应用程序,并刷新页面,我得到了以下错误:

Server Error in '/' Application. Key not valid for use in specified state. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Security.Cryptography.CryptographicException: Key not valid for use in specified state.

Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[CryptographicException: Key not valid for use in specified state. ]
System.Security.Cryptography.ProtectedData.Unprotect(Byte[] encryptedData, Byte[] optionalEntropy, DataProtectionScope scope) +425
Microsoft.IdentityModel.Web.ProtectedDataCookieTransform.Decode(Byte[] encoded) +59

[InvalidOperationException: ID1073: A CryptographicException occurred when attempting to decrypt the cookie using the ProtectedData API (see inner exception for details). If you are using IIS 7.5, this could be due to the loadUserProfile setting on the Application Pool being set to false. ] Microsoft.IdentityModel.Web.ProtectedDataCookieTransform.Decode(Byte[] encoded) +151
Microsoft.IdentityModel.Tokens.SessionSecurityTokenHandler.ApplyTransforms(Byte[] cookie, Boolean outbound) +109
Microsoft.IdentityModel.Tokens.SessionSecurityTokenHandler.ReadToken(XmlReader reader, SecurityTokenResolver tokenResolver) +634
Microsoft.IdentityModel.Tokens.SessionSecurityTokenHandler.ReadToken(Byte[] token, SecurityTokenResolver tokenResolver) +105
Microsoft.IdentityModel.Web.SessionAuthenticationModule.ReadSessionTokenFromCookie(Byte[] sessionCookie) +239
Microsoft.IdentityModel.Web.SessionAuthenticationModule.TryReadSessionTokenFromCookie(SessionSecurityToken& sessionToken) +59
Microsoft.IdentityModel.Web.SessionAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs eventArgs) +52
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

________________________________________ Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927

用户会话中使用SQLServer的会话存储模式,我正在使用一个特殊的数据库。

我已经尝试了很多,我无法在本地计算机(Windows7)上重新处理此问题。 有没有人有类似的经历?你能告诉我如何解决这个问题吗?

回答

0

这很可能是因为您的应用程序池用户没有永久的用户配置文件。为了纠正这个问题,你可以像用户那样运行一些东西:

runas /user:<domain>\<user> cmd 

这将创建配置文件。随后,重新启动IIS后,数据应该可以解密。

+0

我没有验证这是否会解决这个问题,因为这已经很长一段时间了,我不在该项目中,任何人都遇到了这个问题,请添加您的评论。谢谢! – 2012-09-06 05:24:13

2

我最终通过将应用程序池用户更改为本地用户来解决此问题。 这个问题可能是由sso托管在64位操作系统上造成的,如果我在32位计算机上托管sso(即使我使用应用程序池的域用户),也不存在此问题。

现在我使用ApplicationPoolIdentity或NetWork Service,重新启动IIS后异常消失。

谢谢你们,我很高兴与你分享我的解决方案。

+0

好的,最后,我不得不说,这是因为我用于应用程序池的域用户没有一些必需的访问权限,但我不知道什么样的权限。任何人都可以发现,也给我发电子邮件([email protected])? – 2010-02-26 06:12:42

+0

任何人碰到这个,请检查我的答案,因为我认为它是正确的。 – Gaz 2012-09-03 15:32:32

1

似乎有某种安全问题,当你有几个应用程序与IIS 7.5

共享同一个域赢Server 2008上如果有网址http://ourdomain.com/app1http://ourdomain.com/app2您可以登录到一个应用程序使用WIF但当你访问另一个应用程序时,你会得到这个错误。这是因为Cookie是用于域名的,但如果它是由app1创建的,则app2无法访问它。

因此,解决方案是要么像Aaron一样使用具有访问权限的特定用户,要么像我们一样分开两个不同域的应用程序,即http://app1domain.com/http://app2domain.com/

+0

你是什么意思“分开两个不同的域上的应用程序,即http://app1domain.com/和http://app2domain.com/”? 如果我使用http://app1.domain.com和http://app2.domain.com,我仍然有这个问题。 如果我使用域用户,需要什么样的特殊访问权限? – 2010-02-24 05:33:26

+0

首先,我们使用了一个网站(domain.com)和两个虚拟目录app1和app2。我们不得不将它们分成两个不同域的网站(app1domain.com和app2domain.com)以使其运行。您可能还需要两个应用程序池。 我们从未测试过不同的访问权限或用户,但由于您已将其运行,我认为这是一个有效的解决方案。 – 2010-02-24 09:22:07

+0

当然,我试图为域名用户创建两个不同的app1和app2池,但我仍然遇到了问题,如果我使用的是管理员的域用户,那么它与使用ApplicationPoolUser或NetWork Service相同, ,我可以说这是必须的域用户缺少一些访问权限,但我不知道什么权利。 – 2010-02-25 08:38:05