net core 2.2,跨应用共享数据保护令牌
net core 2.2, share data protection tokens across applications
我将多个 .net core 2.2 应用程序发布到单个 IIS 实例。我的数据保护设置是
public static IDataProtectionBuilder AddCaDataProtection(this IServiceCollection services)
{
const string applicationName = "CertificationAuthority";
var registryKey = Registry.CurrentUser.CreateSubKey($@"SOFTWARE\{applicationName}\keys");
return services
.AddDataProtection()
.SetApplicationName(applicationName)
.ProtectKeysWithDpapi()
.PersistKeysToRegistry(registryKey);
}
每个应用程序都从其 Startup.ConfigureServices
调用此静态方法。应用程序 运行 在同一个 windows 用户帐户下的不同池中。虽然,当一个应用程序尝试验证在另一个应用程序中生成的数据保护令牌时,验证失败并显示 InvalidToken 结果。
我做错了什么?
PS。我真正想做的是在一个应用程序中使用 UserManager.GenerateEmailConfirmationTokenAsync
生成代码,然后在另一个应用程序中执行 UserManager.ConfirmEmailAsync
。
问题的原因是应用程序池是 运行 PoolIdentity 凭据,这实际上意味着每个池都有单独的用户配置文件
我将多个 .net core 2.2 应用程序发布到单个 IIS 实例。我的数据保护设置是
public static IDataProtectionBuilder AddCaDataProtection(this IServiceCollection services)
{
const string applicationName = "CertificationAuthority";
var registryKey = Registry.CurrentUser.CreateSubKey($@"SOFTWARE\{applicationName}\keys");
return services
.AddDataProtection()
.SetApplicationName(applicationName)
.ProtectKeysWithDpapi()
.PersistKeysToRegistry(registryKey);
}
每个应用程序都从其 Startup.ConfigureServices
调用此静态方法。应用程序 运行 在同一个 windows 用户帐户下的不同池中。虽然,当一个应用程序尝试验证在另一个应用程序中生成的数据保护令牌时,验证失败并显示 InvalidToken 结果。
我做错了什么?
PS。我真正想做的是在一个应用程序中使用 UserManager.GenerateEmailConfirmationTokenAsync
生成代码,然后在另一个应用程序中执行 UserManager.ConfirmEmailAsync
。
问题的原因是应用程序池是 运行 PoolIdentity 凭据,这实际上意味着每个池都有单独的用户配置文件