cornflourblue/aspnet-core-jwt-authentication-api

Issue about CreateToken

Jafic opened this issue · 2 comments

Jafic commented

hi,the demo can run successful.But when i change appsettings.json file about AppSettings.And i change the Secret string "THIS IS USED TO SIGN AND VERIFY JWT TOKENS, REPLACE IT WITH YOUR OWN SECRET, IT CAN BE ANY STRING" into any word. Then i call the api Authenticate,It is brokes down in method "tokenHandler.CreateToken(tokenDescriptor)",and the wrong info is IDX10603: Decryption failed. Keys tried: '[PII is hidden]'.
Exceptions caught:
'[PII is hidden]'.
token: '[PII is hidden]'
Parameter name: KeySize

Can you please tell me,how to get over this issue.Thanks

Jafic commented

I get the reason, as the HmacSha256 in the line SigningCredentials(signinKey, SecurityAlgorithms.HmacSha256)should be greater than 128 bits. If you meet the same probem,hope it can help you out. Thanks

Hi Jafic, it could be that your secret isn't long enough, another person ran into a similar error and it was caused by the secret length, try a longer string to see if it fixes the issue.