.Net Core warning No XML encryptor configured

You can explicit configure your cryptographic algorithms in the following way in .NET 6. using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption; using Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel; … var builder = WebApplication.CreateBuilder(args); … builder.Services.AddDataProtection().UseCryptographicAlgorithms( new AuthenticatedEncryptorConfiguration { EncryptionAlgorithm = EncryptionAlgorithm.AES_256_CBC, ValidationAlgorithm = ValidationAlgorithm.HMACSHA256 }); Configure ASP.NET Core Data Protection The default EncryptionAlgorithm is AES-256-CBC, and the default ValidationAlgorithm is HMACSHA256. The default … Read more

Populate IConfiguration for unit tests

You can use MemoryConfigurationBuilderExtensions to provide it via a dictionary. using Microsoft.Extensions.Configuration; var myConfiguration = new Dictionary<string, string> { {“Key1”, “Value1”}, {“Nested:Key1”, “NestedValue1”}, {“Nested:Key2”, “NestedValue2”} }; var configuration = new ConfigurationBuilder() .AddInMemoryCollection(myConfiguration) .Build(); The equivalent JSON would be: { “Key1”: “Value1”, “Nested”: { “Key1”: “NestedValue1”, “Key2”: “NestedValue2” } } The equivalent Environment Variables would be … Read more