Skip to content

Commit

Permalink
chore: Made Security:ProtectionCertificate configuration optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Fgruntjes committed Mar 17, 2023
1 parent 4f68e88 commit de28834
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions App.Lib/src/AppWebApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,11 @@ private static void ConfigureDataProtection(WebApplicationBuilder builder)
return;
}

var certificate = builder.Configuration.MustGetValue<string>("Security:ProtectionCertificate");

builder.Services.AddDataProtection()
.ProtectKeysWithCertificate(new X509Certificate2(certificate));
var dataProtectionBuilder = builder.Services.AddDataProtection();
var certificate = builder.Configuration.GetValue<string>("Security:ProtectionCertificate");
if (certificate != null)
{
dataProtectionBuilder.ProtectKeysWithCertificate(new X509Certificate2(certificate));
}
}
}

0 comments on commit de28834

Please sign in to comment.