English 中文(简体)
微软。 身份证明: 特定国家使用无效的关键
原标题:Microsoft.IdentityModel: Key not valid for use in specified state

我有使用视窗身份基金会了解网络应用的信息,除了一个服务器外,这些应用一直运作良好。 我看到事件记录中下文所示错误信息。

Exception information: 
    Exception type: CryptographicException 
    Exception message: Key not valid for use in specified state.

   at System.Security.Cryptography.ProtectedData.Unprotect(Byte[] encryptedData, Byte[] optionalEntropy, DataProtectionScope scope)
   at Microsoft.IdentityModel.Web.ProtectedDataCookieTransform.Decode(Byte[] encoded)

这项申请使用标准很短的电离层电离层电离层电离层装置,编号GAFS v2。 它没有使用RsaEncodeionCookie Transform。 我正在研究如何诊断这一问题的任何建议。 情况 我迄今已尝试:

  1. The Application Pool is using the ASP.NET v4.0 identity which has the "Load User Profile" setting set to true.
  2. I deleted the C:UsersASP.NET v4.0AppData folder and saw this was successfully recreated.
  3. I checked permissions on certificate private keys, which were good. I also tried disabling token encryption which did not make any difference.

任何建议都会得到赞赏。

最佳回答

通常是因为申请无法对认证的象征性 co进行加密。 确保拥有应用程序库的特性能充分允许进入证书库。 Try changing the identity to Networkservice, see that helps.

您还应明确你们的浏览器,以确保你们不会有不同的申请表。

问题回答

The issue is 100% reproducible:

Indeed, after application being re-deployed, AND old authentication cookie is left on the client machine (client did not sign out) -this error appears to the client on any following request. To fix this error client either has to delete the cookies and/or sign-in then sign-out from STS. Once all done - the error goes away and everything is fine until next upgrade....

在进行了一些研究之后,我认为,这是需要固定下来的岛屿会议。 如果你仔细研究上面的 st痕,就有一种令人感兴趣的方法,即TryReadSession TokenFromCookie,该方法预计认证模块将“行业”从厨师那里读到,如果失败的话,将回去不实——《守则》就是其中的:

public bool TryReadSessionTokenFromCookie(out SessionSecurityToken sessionToken)
{
    byte[] sessionCookie = this.CookieHandler.Read();
    if (sessionCookie == null)
    {
        sessionToken = null;
        return false;
    }
    sessionToken = this.ReadSessionTokenFromCookie(sessionCookie);
    if (DiagnosticUtil.TraceUtil.ShouldTrace(TraceEventType.Verbose))
    {
        DiagnosticUtil.TraceUtil.Trace(TraceEventType.Verbose, TraceCode.Diagnostics, SR.GetString("TraceValidateToken", new object[0]), new TokenTraceRecord(sessionToken), null);
    }
    return true;
}

Obviously, the code fails in this method with unhandled error and developer is left without any option to handle the error in more or less reasonable way. (...Or at least I could not find any, since this HTTP module does not pass this error onto HttpApplication object for handling, and throws it in the user s face.) So, I think there are two bugs: 1) Security token handler needs to be more specific on the reasoning of thrown ID1073 (server side decryption error or wrong (old) cookie error) 2) There has to be a way for a developer to handle this error and sign-out the user, if it occurs. I ll take ANY help on this one... Can anyone PLEASE create a sample code, showing how to intercept this exception so user can be automatically signed-out when this error occurs? Again, Application.Error event does not seem to get fired from this module -not sure what else can be done to handle it, other than writing my own SessionAuthenticationModule. ANY HELP IS HIGHLY APPRECIATED!!! Thanks! Alex

我解决了我的案件,因为有两个申请的“FedAuth”名称与“FedAuth”名称相同(按违约名称)。 仅举一个不同的名称,它决心:

<system.identityModel.services>
<federationConfiguration>
  <cookieHandler name="ACookieName" />
</federationConfiguration>

以下是我的工作:

你们需要加入系统。

Reference: SessionSecurityTokenHandler trying to decrypt SessionSecurityToken in RSA-encrypted cookie using DPAPI; why?

  <system.identityModel>
    <identityConfiguration saveBootstrapContext="true">
      <audienceUris>
        <add value="yoursite.com" />
      </audienceUris>
      <issuerNameRegistry type="Thinktecture.IdentityModel.Tokens.MetadataBasedIssuerNameRegistry, Thinktecture.IdentityModel">
        <trustedIssuerMetadata issuerName="urn:federation:company:stage" metadataAddress="https://federation-sts-stage.company.com/FederationMetadata/2007-06/FederationMetadata.xml"></trustedIssuerMetadata>
      </issuerNameRegistry>
      <certificateValidation certificateValidationMode="None" />
<securityTokenHandlers>
     <add type="System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler,  
             System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

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

删除<代码>FedAuth 厨师可以工作。 在例外情况发生时,可在<代码>Application_Error上查阅Global.asax文档:

Microsoft.IdentityModel.Web.FederatedAuthentication.SessionAuthenticationModule.SignOut();

This error doesn t seem to be caught by http application. Please check out http://social.technet.microsoft.com/wiki/contents/articles/1898.aspx#Q1 instead.

This issue is because of insufficient permission. The app pool should have ApplicationPoolIdentity Identity to make it work. Goto your apppool -> Advanced Settings -> Build-in accounts to change the settings





相关问题
AES 256 in CTR mode [closed]

ctr mode makes it possible to use a block cipher as a stream cipher but how strong will be the encryption in this mode ?

Illegalkeysize exception

I am using the Bouncy Castle Java cryptographic algorithm implementation. I am getting an IllegalKeySizeException. To overcome this I have even changed my java security jars (local_policy.jar and ...

Can two different strings generate the same MD5 hash code?

For each of our binary assets we generate a MD5 hash. This is used to check whether a certain binary asset is already in our application. But is it possible that two different binary assets generate ...

Load RSA keys from files

I used openSSL command to create 2 files: 1 for RSA public key & 1 for RSA private key. How do I recover RSA keys using C? Specifically, I have these functions: RSA_public_encrypt(read_num, ...

RSA cryptosystem

Hi i am trying to set up an RSA cryptosystem i have all the values except d selected prime numbers: p=1889, q=2003, n=3783667, phi=3779776, e= 61 i got stuck finding d could anyone help me to figure ...

热门标签