I am using .NET Core 3.1.
On Startup, I am adding the following:
public void ConfigureServices(IServiceCollection services)
{
services.AddHttpClient<IApns, Apns>().ConfigurePrimaryHttpMessageHandler(() =>
{
var handler = new HttpClientHandler { SslProtocols = SslProtocols.Tls12 };
// How do I access memory cache (MyConfig expect it) - normally I use it injected.
var certificate = new MyConfig(...).GetCertificate
handler.ClientCertificates.Add(certificate);
return handler;
});
}
The problem is MyConfig
is a class that expects IMemoryCache
:
public MyConfig(IMemoryCache cache)
{
_cache = cache;
}
The certificate is stored and loaded from memory cache. How do I get around this please?