为什么只有在生产环境(CentOS 7)中才出现此异常?
[ERR]反序列化令牌时引发了异常。 Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: 反伪造令牌无法解密。 -> System.Security.Cryptography.CryptographicException:密钥 在钥匙圈中找不到{d41af177-dd3c-460d-8280-5f46d79ae0e3}
缺少什么?
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddDataProtection()
.SetApplicationName(Security.Application_Name)
.PersistKeysToFileSystem(new
DirectoryInfo(Security.Key_Path));
创建了名为key-dcee8f19-132e-4aff-84f0-7ef8c338533d.xml的文件
要抄写
var serviceCollection = new ServiceCollection();
serviceCollection.AddDataProtection()
.SetApplicationName(Security.Application_Name)
.PersistKeysToFileSystem(new DirectoryInfo(Security.Key_Path));
var services = serviceCollection.BuildServiceProvider();
var instance = ActivatorUtilities.CreateInstance<Cipher>(services);
string _mpid = instance.Decrypt(_xpid);