2010-02-22 122 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