服务器在登录后的部署环境中关闭(错误503)。在开发环境中按预期工作。

huangapple go评论82阅读模式
英文:

Server shuts down (Error 503) on deployed environment after login. on development evironment works as expected

问题

I'm creating an application using .NET 6 LTS and Angular 14. On the development environment (using IIS express) the app behaves normally. However when I deploy the application (release) on Windows 2019 and IIS 10, right after the login the server returns error 503. The application pool and the site have appropriate permissions. (I even tried to allow everyone with full access to verify it).

Below is the web.config file

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\TheFile.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>

And the appsettings.json file is the following

{
  "ConnectionStrings": {
    "DefaultConnection": "<connection string values>"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "Serilog": {
    "Using": [ "Serilog.Sinks.MSSqlServer" ],
    "MinimumLevel": "Information",
    "WriteTo": [
      {
        "Name": "MSSqlServer",
        "Args": {
          "connectionString": "<connection string values>",
          "sinkOptionsSection": {
            "tableName": "EasymintLog",
            "schemaName": "dbo",
            "autoCreateSqlTable": true
          },
          "columnOptionsSection": {
            "disableTriggers": true,
            "clusteredColumnstoreIndex": false,
            "primaryKeyColumnName": "Id",
            "addStandardColumns": [ "LogEvent" ],
            "removeStandardColumns": [ "MessageTemplate", "Properties", "TimeStamp", "Message" ],
            "additionalColumns": [
              {
                "ColumnName": "UserId",
                "DataType": "nvarchar",
                "AllowNull": true,
                "DataLength": 50
              },
              {
                "ColumnName": "ControllerAction",
                "DataType": "nvarchar",
                "AllowNull": true,
                "DataLength": 10
              },
              {
                "ColumnName": "Request",
                "DataType": "nvarchar"
              },
              {
                "ColumnName": "Response",
                "DataType": "nvarchar"
              },
              {
                "ColumnName": "StatusCode",
                "DataType": "int",
                "AllowNull": true
              },
              {
                "ColumnName": "LogDate",
                "DataType": "datetime2",
                "AllowNull": true
              },
              {
                "ColumnName": "ClientAddress",
                "DataType": "nvarchar",
                "AllowNull": true,
                "DataLength": 15
              },
              {
                "ColumnName": "InnerException",
                "DataType": "nvarchar"
              }
            ],
            "id": { "nonClusteredIndex": true },
            "level": {
              "columnName": "Severity",
              "storeAsEnum": false
            },
            "timeStamp": {
              "columnName": "Timestamp"
            },
            "logEvent": {
              "excludeAdditionalProperties": true,
              "excludeStandardColumns": true
            },
            "message": { "columnName": "Message" },
            "exception": { "columnName": "Exception" }
          }
        }
      }
    ]
  },
  "IdentityServer": {
    "Key": {
      "Type": "Development"
    },
    "Clients": {
      "NextStepNG": {
        "Profile": "IdentityServerSPA"
      }
    }
  },
  "AllowedHosts": "*"
}

I don't know if there is an issue with the app Startup.cs file, which is the following...

// The provided C# code for Startup.cs is too long to fit in a single response. If you have specific questions or need assistance with a particular part of the code, please let me know.

What should I check and how to proceed? Anyone faced the same issue before?

I tried altering permissions and various settings in IIS based on the info I've found here and Google. The result remained the same.

Based on the info I found in the Windows Event Viewer, it shows the following error

Category: Duende.IdentityServer.Services.KeyManagement.KeyManager
EventId: 0
SpanId: b248d52022677998
TraceId: 01ac174a5bdcbb9ec7a8aec2e95a16be
ParentId: 0000000000000000
RequestId: 80000042-0001-fc00-b63f-84710c7967bb
RequestPath: /.well-known/openid-configuration

Error unprotecting key with kid FB30056547480314CDD1824BFB8D469F.

Exception:
System.Security.Cryptography.CryptographicException: The key {a6be54e5-5ff8-4fb4-90aa-eb89fa686bc0} was not found in the key ring. For more information go to http://aka.ms/dataprotectionwarning
   at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus& status)
   at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[] protectedData)
   at Microsoft.AspNetCore.DataProtection.DataProtectionCommonExtensions.Unprotect(IDataProtector protector, String protectedData)
   at Duende.IdentityServer.Services.KeyManagement.DataProtectionKeyProtector.Unprotect(SerializedKey key) in /_/src/IdentityServer/Services/Default/KeyManagement/DataProtectionKeyProtector.cs:line 56
   at Duende.IdentityServer.Services.KeyManagement.KeyManager.<GetKeysFromStoreAsync>b__20_0(SerializedKey x) in /_/src/IdentityServer/Services/Default/KeyManagement/KeyManager.cs:line 426

Please help, as I haven't encountered this before and I've deployed .NET core apps in the past with no issue.

PS. The app is run locally and there is no issue with firewall or antivirus.

英文:

I'm creating an application using NET 6 LTS and Angular 14. On the development environment (using IIS express) the app behaves normally. However when I deploy the application (release) on Windows 2019 and IIS 10, right after the login the server returns error 503. The application pool and the site have appropriate permissions. (I even tried to allow everyone with full access to verify it).

below is the web.config file

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;configuration&gt;
&lt;location path=&quot;.&quot; inheritInChildApplications=&quot;false&quot;&gt;
&lt;system.webServer&gt;
&lt;handlers&gt;
&lt;add name=&quot;aspNetCore&quot; path=&quot;*&quot; verb=&quot;*&quot; modules=&quot;AspNetCoreModuleV2&quot; resourceType=&quot;Unspecified&quot; /&gt;
&lt;/handlers&gt;
&lt;aspNetCore processPath=&quot;dotnet&quot; arguments=&quot;.\TheFile.dll&quot; stdoutLogEnabled=&quot;false&quot; stdoutLogFile=&quot;.\logs\stdout&quot; hostingModel=&quot;inprocess&quot; /&gt;
&lt;/system.webServer&gt;
&lt;/location&gt;
&lt;/configuration&gt;

and the appsettings.json file is the following

{
&quot;ConnectionStrings&quot;: {
&quot;DefaultConnection&quot;: &quot;&lt;connection string values&gt;&quot;
},
&quot;Logging&quot;: {
&quot;LogLevel&quot;: {
&quot;Default&quot;: &quot;Information&quot;,
&quot;Microsoft&quot;: &quot;Warning&quot;,
&quot;Microsoft.Hosting.Lifetime&quot;: &quot;Information&quot;
}
},
&quot;Serilog&quot;: {
&quot;Using&quot;: [ &quot;Serilog.Sinks.MSSqlServer&quot; ],
&quot;MinimumLevel&quot;: &quot;Information&quot;,
&quot;WriteTo&quot;: [
{
&quot;Name&quot;: &quot;MSSqlServer&quot;,
&quot;Args&quot;: {
&quot;connectionString&quot;: &quot;&lt;connection string values&gt;&quot;,
&quot;sinkOptionsSection&quot;: {
&quot;tableName&quot;: &quot;EasymintLog&quot;,
&quot;schemaName&quot;: &quot;dbo&quot;,
&quot;autoCreateSqlTable&quot;: true
//&quot;batchPostingLimit&quot;: 50,
//&quot;period&quot;: &quot;0.00:00:05&quot;
},
//&quot;restrictedToMinimumLevel&quot;: &quot;Warning&quot;,
&quot;columnOptionsSection&quot;: {
&quot;disableTriggers&quot;: true,
&quot;clusteredColumnstoreIndex&quot;: false,
&quot;primaryKeyColumnName&quot;: &quot;Id&quot;,
&quot;addStandardColumns&quot;: [ &quot;LogEvent&quot; ],
&quot;removeStandardColumns&quot;: [ &quot;MessageTemplate&quot;, &quot;Properties&quot;, &quot;TimeStamp&quot;, &quot;Message&quot; ],
&quot;additionalColumns&quot;: [
{
&quot;ColumnName&quot;: &quot;UserId&quot;,
&quot;DataType&quot;: &quot;nvarchar&quot;,
&quot;AllowNull&quot;: true,
&quot;DataLength&quot;: 50
},
{
&quot;ColumnName&quot;: &quot;ControllerAction&quot;,
&quot;DataType&quot;: &quot;nvarchar&quot;,
&quot;AllowNull&quot;: true,
&quot;DataLength&quot;: 10
},
{
&quot;ColumnName&quot;: &quot;Request&quot;,
&quot;DataType&quot;: &quot;nvarchar&quot;
},
{
&quot;ColumnName&quot;: &quot;Response&quot;,
&quot;DataType&quot;: &quot;nvarchar&quot;
},
{
&quot;ColumnName&quot;: &quot;StatusCode&quot;,
&quot;DataType&quot;: &quot;int&quot;,
&quot;AllowNull&quot;: true
},
{
&quot;ColumnName&quot;: &quot;LogDate&quot;,
&quot;DataType&quot;: &quot;datetime2&quot;,
&quot;AllowNull&quot;: true
},
{
&quot;ColumnName&quot;: &quot;ClientAddress&quot;,
&quot;DataType&quot;: &quot;nvarchar&quot;,
&quot;AllowNull&quot;: true,
&quot;DataLength&quot;: 15
},
{
&quot;ColumnName&quot;: &quot;InnerException&quot;,
&quot;DataType&quot;: &quot;nvarchar&quot;
}
],
&quot;id&quot;: { &quot;nonClusteredIndex&quot;: true },
&quot;level&quot;: {
&quot;columnName&quot;: &quot;Severity&quot;,
&quot;storeAsEnum&quot;: false
},
&quot;timeStamp&quot;: {
&quot;columnName&quot;: &quot;Timestamp&quot;
//&quot;convertToUtc&quot;: true
},
&quot;logEvent&quot;: {
&quot;excludeAdditionalProperties&quot;: true,
&quot;excludeStandardColumns&quot;: true
},
&quot;message&quot;: { &quot;columnName&quot;: &quot;Message&quot; },
&quot;exception&quot;: { &quot;columnName&quot;: &quot;Exception&quot; }
//&quot;messageTemplate&quot;: { &quot;columnName&quot;: &quot;Template&quot; }
}
}
}
]
},
&quot;IdentityServer&quot;: {
&quot;Key&quot;: {
&quot;Type&quot;: &quot;Development&quot;
},
&quot;Clients&quot;: {
&quot;NextStepNG&quot;: {
&quot;Profile&quot;: &quot;IdentityServerSPA&quot;
}
}
},
&quot;AllowedHosts&quot;: &quot;*&quot;,
//SMTP settings
//&quot;SMTP&quot;: {
//  &quot;Host&quot;: &quot;&quot;,
//  &quot;From&quot;: &quot;NextStep Notifications&quot;,
//  &quot;Port&quot;: 587, //25,
//  &quot;UseSSL&quot;: true,
//  &quot;Username&quot;: &quot;&quot;,
//  &quot;Password&quot;: &quot;&quot;
//},
}

I don't know if there is an issue with the app startup.cs file.
Which is the following...

using AutoMapper;
using Duende.IdentityServer.Services;
using IdempotentAPI.Cache.DistributedCache.Extensions.DependencyInjection;
using IdempotentAPI.Cache.FusionCache.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using NextStepNG.BusinessLogic.CommonBLs;
using NextStepNG.BusinessLogic.EshopBLs;
using NextStepNG.Data;
using NextStepNG.Data.EFCore.Common;
using NextStepNG.Data.EFCore.Company;
using NextStepNG.Data.EFCore.Eshop;
using NextStepNG.Data.EFCore.Organization;
using NextStepNG.Data.EFCore.Person;
using NextStepNG.Enums;
using NextStepNG.Models;
using NextStepNG.Services;
using NextStepNG.Utils.Common;
using Serilog;
using System;
using System.Security.Claims;
namespace NextStepNG
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt;
options.UseSqlServer(
Configuration.GetConnectionString(&quot;DefaultConnection&quot;),
sqlServerOptionsAction: sqlOptions =&gt;
{
sqlOptions.EnableRetryOnFailure();
}));
services.AddDbContext&lt;NEXTSTEPNGContext&gt;(options =&gt;
options.UseSqlServer(
Configuration.GetConnectionString(&quot;DefaultConnection&quot;),
sqlServerOptionsAction: sqlOptions =&gt;
{
sqlOptions.EnableRetryOnFailure();
}));
services.AddDistributedMemoryCache();
services.AddIdempotentAPIUsingDistributedCache();
//services.AddIdempotentAPIUsingFusionCache();
//services.AddFusionCacheNewtonsoftJsonSerializer();            
services.AddTransient&lt;IProfileService, ProfileService&gt;();
services.AddDefaultIdentity&lt;ApplicationUser&gt;(options =&gt; options.SignIn.RequireConfirmedAccount = true)
.AddRoles&lt;IdentityRole&gt;()
.AddEntityFrameworkStores&lt;ApplicationDbContext&gt;();
services.AddIdentityServer(options =&gt;
{
// new key every 30 days
options.KeyManagement.RotationInterval = TimeSpan.FromDays(30);
// announce new key 2 days in advance in discovery
options.KeyManagement.PropagationTime = TimeSpan.FromDays(2);
// keep old key for 7 days in discovery for validation of tokens
options.KeyManagement.RetentionDuration = TimeSpan.FromDays(7);
// don&#39;t delete keys after their retention period is over
options.KeyManagement.DeleteRetiredKeys = false;
})
.AddApiAuthorization&lt;ApplicationUser, ApplicationDbContext&gt;()
.AddProfileService&lt;ProfileService&gt;();
services.AddTransient&lt;IEmailSender, EmailSender&gt;();
services.AddAuthentication()
.AddIdentityServerJwt();
services.AddAuthorization(options =&gt;
{
options.AddPolicy(AuthorizationEnum.Roles.Developer.ToString(), policy =&gt;
policy.RequireClaim(ClaimTypes.Role, AuthorizationEnum.Claims.developer.ToString()));
options.AddPolicy(AuthorizationEnum.Roles.Easymint.ToString(), policy =&gt;
policy.RequireClaim(ClaimTypes.Role, AuthorizationEnum.Claims.easymint.ToString()));
options.AddPolicy(AuthorizationEnum.Roles.Administrator.ToString(), policy =&gt;
policy.RequireClaim(ClaimTypes.Role, AuthorizationEnum.Claims.administrator.ToString()));
options.AddPolicy(AuthorizationEnum.Roles.Manager.ToString(), policy =&gt;
policy.RequireClaim(ClaimTypes.Role, AuthorizationEnum.Claims.manager.ToString()));
options.AddPolicy(AuthorizationEnum.Roles.Tester.ToString(), policy =&gt;
policy.RequireClaim(ClaimTypes.Role, AuthorizationEnum.Claims.tester.ToString()));
options.AddPolicy(AuthorizationEnum.Roles.User.ToString(), policy =&gt;
policy.RequireClaim(ClaimTypes.Role, AuthorizationEnum.Claims.user.ToString()));
});
services.AddControllersWithViews();
services.AddRazorPages();
services.AddControllers();
services.AddMvc();
// In production, the Angular files will be served from this directory
services.AddSpaStaticFiles(configuration =&gt;
{
configuration.RootPath = &quot;ClientApp/dist&quot;;
});
services.AddScoped&lt;LoggingActionFilter&gt;();
services.AddMemoryCache();
services.AddMvc().AddJsonOptions(options =&gt;
options.JsonSerializerOptions.PropertyNamingPolicy = null);
services.AddLogging(loggingBuilder =&gt;
loggingBuilder.AddSerilog(dispose: true));
services.Configure&lt;ForwardedHeadersOptions&gt;(options =&gt;
{
options.ForwardedHeaders =
ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
});
services.AddDatabaseDeveloperPageExceptionFilter();
services.AddAutoMapper(typeof(Startup));
services.AddScoped&lt;CountryRepository&gt;();
services.AddScoped&lt;LocaleRepository&gt;();
services.AddScoped&lt;RolesRepository&gt;();
services.AddScoped&lt;UserSettingsRepository&gt;();
services.AddScoped&lt;OrganizationLocaleRepository&gt;();
services.AddScoped&lt;OrganizationsRepository&gt;();
services.AddScoped&lt;PersonsRepository&gt;();
services.AddScoped&lt;OrganizationBanksRepository&gt;();
services.AddScoped&lt;AddressesRepository&gt;();
services.AddScoped&lt;BanksRepository&gt;();
services.AddScoped&lt;FullDetailsInfoRepository&gt;();
services.AddScoped&lt;CompaniesRepository&gt;();
services.AddScoped&lt;CompanyBankAccountsRepository&gt;();
services.AddScoped&lt;CompanyDetailsRepository&gt;();
services.AddScoped&lt;CompanyIRSRepository&gt;();
services.AddScoped&lt;CustomerDetailsInfoRepository&gt;();
services.AddScoped&lt;OrganizationDetailsRepository&gt;();
services.AddScoped&lt;OrganizationIRSRepository&gt;();
services.AddScoped&lt;OrganizationBankAccountRepository&gt;();
services.AddScoped&lt;UsersManagementBL&gt;();
services.AddScoped&lt;EmployeeManagementBL&gt;();
services.AddScoped&lt;EmployeeManagementRepository&gt;();
services.AddScoped&lt;PersonsBL&gt;();
services.AddScoped&lt;EshopLicenseTypesRepository&gt;();
services.AddScoped&lt;RepairsRepository&gt;();
//services.AddScoped&lt;EshopUsersBL&gt;();
services.AddSingleton(provider =&gt; Configuration);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseForwardedHeaders();
}
else
{
app.UseExceptionHandler(&quot;/Error&quot;);
app.UseForwardedHeaders();
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseXContentTypeOptions();
app.UseReferrerPolicy(r =&gt; r.StrictOriginWhenCrossOrigin());
app.UseXDownloadOptions();
app.UseXRobotsTag(r =&gt; r
.NoFollow()
.NoIndex());
app.UseXXssProtection(x =&gt; x.Enabled());
//app.UseMiddleware&lt;StackifyMiddleware.RequestTracerMiddleware&gt;(); //debug only
app.UseHttpsRedirection();
app.UseStaticFiles();
//nwebsec section
//app.UseCsp(options =&gt; options.DefaultSources(s =&gt; s.Self()
//.CustomSources(&quot;https://cdn3.devexpress.com/jslib/19.2.6/css/dx.light.css&quot;,
//    &quot;https://cdn3.devexpress.com/jslib/19.2.6/css/icons/dxicons.woff&quot;,
//    &quot;https://cdn3.devexpress.com/jslib/19.2.6/css/icons/dxicons.woff2&quot;,
//    &quot;https://cdn3.devexpress.com/jslib/19.2.6/css/icons/dxicons.ttf&quot;)));
app.UseCsp(options =&gt; options
.FrameAncestors(f =&gt; f.Self()));
//.ScriptSources(f =&gt; f.Self())
//.ReportUris(r =&gt; r.Uris(&quot;/reports&quot;)));
if (!env.IsDevelopment())
{
app.UseSpaStaticFiles();
}
app.UseRouting();
app.UseAuthentication();
app.UseIdentityServer();
app.UseAuthorization();
app.UseEndpoints(endpoints =&gt;
{
endpoints.MapControllerRoute(
name: &quot;default&quot;,
pattern: &quot;{controller}/{action=Index}/{id?}&quot;);
endpoints.MapRazorPages();
endpoints.MapControllerRoute(
name: &quot;default&quot;,
pattern: &quot;{controller}/{action=Index}/{operation}/{id?}&quot;);
endpoints.MapControllerRoute(
name: &quot;default&quot;,
pattern: &quot;{controller}/{action=Index}&quot;);
endpoints.MapRazorPages();
});
app.UseSpa(spa =&gt;
{
//To learn more about options for serving an Angular SPA from ASP.NET Core,
//see https://go.microsoft.com/fwlink/?linkid=864501
spa.Options.SourcePath = &quot;ClientApp&quot;;
if (env.IsDevelopment())
{
//spa.UseAngularCliServer(npmScript: &quot;start&quot;);
//comment the line below before deployment
spa.UseProxyToSpaDevelopmentServer(&quot;http://localhost:4200&quot;);
}
});
}
}
}

What should I check and how to proceed ? Anyone faced the same issue before ?
Thank you in advance

I tried altering permissions and various settings in IIS based on the info I've found here and google. The result remained the same.

Based on the info I found on the windows event viewer it shows the following error

Category: Duende.IdentityServer.Services.KeyManagement.KeyManager
EventId: 0
SpanId: b248d52022677998
TraceId: 01ac174a5bdcbb9ec7a8aec2e95a16be
ParentId: 0000000000000000
RequestId: 80000042-0001-fc00-b63f-84710c7967bb
RequestPath: /.well-known/openid-configuration
Error unprotecting key with kid FB30056547480314CDD1824BFB8D469F.
Exception: 
System.Security.Cryptography.CryptographicException: The key {a6be54e5-5ff8-4fb4-90aa-eb89fa686bc0} was not found in the key ring. For more information go to http://aka.ms/dataprotectionwarning
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus&amp; status)
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[] protectedData)
at Microsoft.AspNetCore.DataProtection.DataProtectionCommonExtensions.Unprotect(IDataProtector protector, String protectedData)
at Duende.IdentityServer.Services.KeyManagement.DataProtectionKeyProtector.Unprotect(SerializedKey key) in /_/src/IdentityServer/Services/Default/KeyManagement/DataProtectionKeyProtector.cs:line 56
at Duende.IdentityServer.Services.KeyManagement.KeyManager.&lt;GetKeysFromStoreAsync&gt;b__20_0(SerializedKey x) in /_/src/IdentityServer/Services/Default/KeyManagement/KeyManager.cs:line 426

Please help, as I haven't encountered this before and I've deployed .NET core apps in the past with no issue.

PS. the app is run locally and there is no issue with firewall or anti virus

答案1

得分: 1

当你在日志中看到这个错误时,这意味着数据保护 API 没有正确配置。

密钥 {a6be54e5-5ff8-4fb4-90aa-eb89fa686bc0} 未在密钥环中找到。有关更多信息,请访问 http://aka.ms/dataprotectionwarning

问题在于,如果未正确配置,每次部署都会重新生成加密密钥,而更改加密密钥意味着所有先前发放的 Cookie 不再有效。

上面的错误意味着未找到解密会话 Cookie 的密钥。

我之前在这里博客中讨论过数据保护:
https://www.edument.se/post/storing-the-asp-net-core-data-protection-key-ring-in-azure-key-vault?lang=en

下面的图片概述了如何配置数据保护 API。

服务器在登录后的部署环境中关闭(错误503)。在开发环境中按预期工作。

英文:

when you get this error in the logs, then that means that the Data Protection API is not properly configured.

The key {a6be54e5-5ff8-4fb4-90aa-eb89fa686bc0} was not found in the key ring. For more information go to http://aka.ms/dataprotectionwarning

The issue is that the encryption key is re-generated on each deployment if not properly configured and changing the encryption key means that all previously issued cookies are no longer valid.

The error you get above means that the key to decrypt the session cookie was not found.

I did blog about data protection here for some time ago
https://www.edument.se/post/storing-the-asp-net-core-data-protection-key-ring-in-azure-key-vault?lang=en

The picture below outlines how you can configure the data protection API.

服务器在登录后的部署环境中关闭(错误503)。在开发环境中按预期工作。

huangapple
  • 本文由 发表于 2023年6月2日 00:42:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76384055.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定