簡體   English   中英

無法將聲明Cookie從.NET 4.5解密到.NET 3.5

[英]Unable to decrypt claims cookie from .NET 4.5 to .NET 3.5

我一直在努力使以下情況在沒有運氣的情況下工作約一周。 我有2個應用程序,一個啟用了聲明的.NET 4.5應用程序,它運行良好(與其他.NET 4及更高版本的應用程序一起使用); 以及使用WebForms .NET 3.5構建的舊Intranet系統。 舊版應用程序無法升級到.NET的更高版本(會容易得多)。

我想發生的是,當我登錄.NET 4.5應用程序時,在訪問.NET 3.5應用程序時需要進行身份驗證。 我已確保應用程序之間的Cookie名稱相同,並且web.config中的machineKey值相同(即使在Web場方案中,我也使用MachineKeySessionSecurityTokenHandler來確保加密的Cookie值相同); 但是,發生的事情是,當我移至.NET 3.5應用程序時,我從SymmetricEncryptionFormatter類得到以下錯誤:

ID0006:輸入的字符串參數為null或為空參數名稱:值

我嘗試將MachineKey密鑰(decryptionkey / validationkey / validation / decryptiom)更改為各種不同的組合(確保它們在兩個站點之間是一致的)。 我可以看到當我去兩個站點時,具有相同cookie值的相同cookie是可見的。 我認為該問題可能與.NET 3.5和.NET 4.5之間的密碼學更改有關(請參閱此處[http://blogs.msdn.com/b/webdev/archive/2012/10/23/cryptographic-improvements-在-ASP凈4-5-PT-2.aspx])

是否有人對導致此問題的原因有任何想法?

.NET 4.5應用程序Web.config中的關鍵條目:

<system.identityModel>
<identityConfiguration>
<securityTokenHandlers>
<remove type="System.IdentityModel.Tokens.SessionSecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add type="System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />  
</securityTokenHandlers>
</identityConfiguration>
</system.identityModel>

<authentication mode="None" />

<system.identityModel.services>
<federationConfiguration>
<cookieHandler requireSsl="false" name="TestName" />
<wsFederation passiveRedirectEnabled="true" issuer="http://localhost:51318/" realm="http://localhost:57083/" persistentCookiesOnPassiveRedirects="true" requireHttps="false" />
</federationConfiguration>
</system.identityModel.services>

.NET 3.5應用程序Web.config中的關鍵條目:

<authentication mode="None"/>

<machineKey decryptionKey="CC510DF4..." validationKey="BEAC835EEC..." />

<microsoft.identityModel>
<service>
  <securityTokenHandlers>
    <!-- Replace the SessionSecurityTokenHandler with our own. -->
    <remove type="Microsoft.IdentityModel.Tokens.SessionSecurityTokenHandler, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <add type="MachineKeySessionSecurityTokenHandler, App_Code"/>
  </securityTokenHandlers>
</service>
</microsoft.identityModel>

<microsoft.identityModel.services>
<federationConfiguration>
<wsFederation passiveRedirectEnabled="true" issuer="http://localhost:51318/" realm="http://localhost:57083/" requireHttps="false"/>
<cookieHandler requireSsl="false" name="TestName"/>
</federationConfiguration>
</microsoft.identityModel.services>

Cookie的內部格式已在WIF和.NET 4.5之間更改。 您不能在兩個版本之間共享它們。

而是將兩個應用程序都指向同一個STS,並讓每個應用程序使用各自的會話cookie。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM