I'm unable to use the builder methods AddDeveloperSigningCredential() or AddSigningCredential() to configure my certificate in code during app startup. If I keep the appsettings entry for Identity Server like so:
"IdentityServer": {
"Key": {
"Type": "Store",
"StoreName": "My",
"StoreLocation": "CurrentUser",
"Name": "CN=MyApplication"
}
}
It will take this config and find the certificate this way, ignoring the manual certificate config methods above.
If I remove the previous config from appsettings and try to use only the certificate config methods, I get an exception:
NullReferenceException: Object reference not set to an instance of an object.
Microsoft.Extensions.DependencyInjection.IdentityServerBuilderConfigurationExtensions+<>c.<AddSigningCredentials>b__10_2(IServiceProvider sp)
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor<TArgument, TResult>.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
So it seems Identity Server 4 requires this appsettings config, and I cannot override it with the certificate config methods mentioned. The methods have to be used somehow, what am I doing wrong?