Search code examples
authenticationsecuritytokenidentityserver4identity

IdentityServer4 in NetCore, tokens lost on restart


I am facing an issue with IdentityServer4. Whenever I restart the server, the tokens get deleted from memory and the users have to re-identify themselves. I need these tokens to persist and not get lost on server reboot or crash... I have been informed that there is a way to store them on disk, but I am unsure of how to do it. Can someone please assist me with the configuration required to achieve this? Thank you!


Solution

  • After a long time it has been discovered what caused the problem of the Jwt tokens, which are not the reference tokens, no problems have been detected in the persistence in the database, what has been seen is that the cryptographic key used by these self-contained tokens is lost in each server restart; This is due to an implementation error and leaving "UseTemporarySigningKeyForDevelopment" option active, the problem will be solved using a .PFX file in the options "UseSigningCertificatePfxFile" and "UseValidationCertificatePfxFile", and thus we ensure that when restarting the machine the cryptographic key is maintained and thus the tokens generated before the restart are still validated correctly.