title: An exception was thrown while deserializing the token.The antiforgery token could not be decrypted in .Net Core 2.2 application
body: <p>I am getting the error in my log. I spent most of my day finding the solution but could not find the one which meets my requirement.</p>
  <p>Here is the log error</p>
  <blockquote>
  <p>severity=[ERROR], ipaddress=xxxx,
  subprocess=Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgery,
  description=An exception was thrown while deserializing the token.
  Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The
  antiforgery token could not be decrypted. ---&gt;
  System.Security.Cryptography.CryptographicException: The key
  {xxxxxxxxxx} was not found in the key ring.    at
  Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[]
  protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus&amp;
  status)    at
  Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.DangerousUnprotect(Byte[]
  protectedData, Boolean ignoreRevocationErrors, Boolean&amp;
  requiresMigration, Boolean&amp; wasRevoked)    at
  Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[]
  protectedData)    at
  Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgeryTokenSerializer.Deserialize(String
  serializedToken)    at
  Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgeryTokenSerializer.Deserialize(String
  serializedToken)    at
  Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgery.GetCookieTokenDoesNotThrow(HttpContext
  httpContext)</p>
  </blockquote>
  <pre><code>    &quot;Certificates&quot;: {
      &quot;StoreName&quot;: &quot;My&quot;,
      &quot;StoreLocation&quot;: &quot;LocalMachine&quot;
      &quot;SerialNumber&quot;: &quot;xxxxxxxxxxxx&quot;
  },
     
     private X509Certificate2 LCertificate()
      {
          var storeName = Configuration[&quot;Certificates:StoreName&quot;];
          var storeLocation = Configuration[&quot;Certificates:StoreLocation&quot;];
          string serialNumber = Configuration[&quot;Certificates: SerialNumber&quot;];
          using(X509Store store = new X509Store(storeName,storeLocation))
          {
              var certificates = store.Certificates
                                      .Find(X509FindType.FindBySerialNumber,
                                            serialNumber,
                                            acceptValidCertOnly);             
  
              return certificates[0];
          }
      }
      
       public void ConfigureServices(IServiceCollection services)
      {
          services.AddIdentityServer
                  .AddSigningCredential(new X509Certificate2(LCertificate()))
        
      }
  
     [HttpPost]
      [ValidateAntiForgeryToken]
      public async Task&lt;IActionResult&gt; Login(LoginModel model)
      {
  </code></pre>