Closed
Description
Describe the bug
I use
services.AddDataProtection().PersistKeysToFileSystem(new DirectoryInfo(filesharePath);
to generate data-protection keys. This produces the issue on initial application startup and possibly the same may happen during rotation of data-protection key. What essentially happens is:
- 2 or more instances of app on startup detect that there is no data-protection key in the fileshare
- 2 or more instances generate the key thus the pods have different data-protection keys for next 24 hours unless I force pods to restart. This causes for example issues with antiforgery tokens not being accepted by instances running on other pods.
The same may probably happen when the existing data-protection key is near expiration time and 2 instances running on separate pods decide do generate the new data-protection key.
Is it possible to do something about it?
To Reproduce
Use
services.AddDataProtection().PersistKeysToFileSystem(new DirectoryInfo(filesharePath);
and deploy your ASP.NET Core app two few pods.
Exceptions (if any)
Further technical details
- ASP.NET Core version 3.1