diff --git a/App.Lib/src/AppWebApplication.cs b/App.Lib/src/AppWebApplication.cs index 62c8ad4..8c7e84b 100644 --- a/App.Lib/src/AppWebApplication.cs +++ b/App.Lib/src/AppWebApplication.cs @@ -188,9 +188,11 @@ private static void ConfigureDataProtection(WebApplicationBuilder builder) return; } - var certificate = builder.Configuration.MustGetValue("Security:ProtectionCertificate"); - - builder.Services.AddDataProtection() - .ProtectKeysWithCertificate(new X509Certificate2(certificate)); + var dataProtectionBuilder = builder.Services.AddDataProtection(); + var certificate = builder.Configuration.GetValue("Security:ProtectionCertificate"); + if (certificate != null) + { + dataProtectionBuilder.ProtectKeysWithCertificate(new X509Certificate2(certificate)); + } } }