[英]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.