title: IDX10503: Signature validation failed. Token does not have a kid. Keys tried: 'System.Text.StringBuilder'
body: <p>I have the below JWT token,</p>
  <pre><code>eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJjbGllbnRpZCIsImF1ZCI6ImNsaWVudGlkIiwic3ViIjoiMTIzIiwiYSI6IjQ1NiIsImlhdCI6MTYyMTc5OTU5OCwiZXhwIjoxNjIxNzk5NjU4fQ.hglbX63zhPwTOsB-zSiOMfxEKl5OaIk6zX1o9-LEhP3nro8fa5_3QyIH7I5971j-xuO1bccX1TOh0kNcQ-ACAg
  </code></pre>
  <p>Which is generated using,</p>
  <pre><code>    public static string GenerateToken(string key, string a1, string a2)
      {
          var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(key));
          var token = new JwtSecurityToken(
              claims: new Claim[]
              {
              new Claim(JwtRegisteredClaimNames.Iss, &quot;clientid&quot;),
              new Claim(JwtRegisteredClaimNames.Aud, &quot;clientid&quot;),
              new Claim(JwtRegisteredClaimNames.Sub, a1),
              new Claim(&quot;a&quot;, a2),
              new Claim(JwtRegisteredClaimNames.Iat, DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(), ClaimValueTypes.Integer64),
              },
              //notBefore: new DateTimeOffset(DateTime.Now).DateTime,
              expires: new DateTimeOffset(DateTime.Now.AddMinutes(1)).DateTime,
              signingCredentials: new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha512)
          );
  
          return new JwtSecurityTokenHandler().WriteToken(token);
      }
  
  var key = &quot;Ym7AD3OT2kpuIRcVAXCweYhV64B0Oi9ETAO6XRbqB8LDL3tF4bMk9x/59PljcGbP5v38BSzCjD1VTwuO6iWA8uzDVAjw2fMNfcT2/LyRlMOsynblo3envlivtgHnKkZj6HqRrG5ltgwy5NsCQ7WwwYPkldhLTF+wUYAnq28+QnU=&quot;;
  // Key is test                
  var token = GenerateToken(key, &quot;123&quot;, &quot;456&quot;);
  </code></pre>
  <p>After getting token I am validating using below code,</p>
  <pre><code>var key = &quot;Ym7AD3OT2kpuIRcVAXCweYhV64B0Oi9ETAO6XRbqB8LDL3tF4bMk9x/59PljcGbP5v38BSzCjD1VTwuO6iWA8uzDVAjw2fMNfcT2/LyRlMOsynblo3envlivtgHnKkZj6HqRrG5ltgwy5NsCQ7WwwYPkldhLTF+wUYAnq28+QnU=&quot;;
  // key is test
  
  var hmac = new HMACSHA512(Convert.FromBase64String(key));
  var validationParameters = new TokenValidationParameters
              {
                  ValidAudience = &quot;clientid&quot;,
                  ValidIssuer = &quot;clientid&quot;,
                  IssuerSigningKey = new SymmetricSecurityKey(hmac.Key)
              };
              var tokenHandler = new JwtSecurityTokenHandler();
              return tokenHandler.ValidateToken(token, validationParameters, out var validToken);
  </code></pre>
  <p>But I am getting below error,</p>
  <pre><code>IDX10503: Signature validation failed. Token does not have a kid. Keys tried: 'System.Text.StringBuilder'.
  Exceptions caught:
   'System.Text.StringBuilder'.
  token: 'System.IdentityModel.Tokens.Jwt.JwtSecurityToken'.
  </code></pre>