Is JwtSecurityTokenHandler thread safe

Viewed 1640

I'm using JwtSecurityTokenHandler to issue tokens in a aspnet core web api app:

JwtSecurityToken token = BuildJwtSecurityToken(...);
public string toks = new JwtSecurityTokenHandler().WriteToken(token);

each time a token is requested and created, a new JwtSecurityTokenHandler is instantiated, can I use a global instance of it and use it for every token generation?

private JwtSecurityTokenHandler handler = new JwtSecurityTokenHandler();
private GenToken(JwtSecurityToken token) => handler.WriteToken(token);

Is there any problems to use like this?

2 Answers
Related