If you delete code block from appsettings.json
it would throw an exception. That's because extension method .AddApiAuthorization<User, DataContext>();
calls internally AddSigningCredentials()
, which reads bare private keys. According to this issue https://github.com/dotnet/runtime/issues/27658#issuecomment-454572342
App Service on Linux read PFX key
Solution
- Delete method
.AddApiAuthorization<User, DataContext>();
and callvar builder = services.AddIdentityServer() .AddAspNetIdentity<ApplicationUser>() .AddOperationalStore<ApplicationDbContext>() .AddIdentityResources() .AddApiResources() .AddClients(); if (Env.IsDevelopment()){ builder.AddDeveloperSigningCredential(); }else{ var bytes = File.ReadAllBytes($"/var/ssl/private/{Configuration["WEBSITE_LOAD_CERTIFICATES"]}.p12"); var certificate = new X509Certificate2(bytes); builder.AddSigningCredentials(certificate); }