Hi,
Can you try this solution. https://support.abp.io/QA/Questions/3537/OpenIddict-WindowsCryptographicException-Access-is-denied
Hi I don't have IIS on my local machine. I am not deploying an application. I am running a project locally for development and am getting this error.
2 createCsp, Func
2 createCng)
[auth-server_41eb61d1-e]: at Internal.Cryptography.Pal.CertificatePal.GetRSAPrivateKey()
[auth-server_41eb61d1-e]: at Internal.Cryptography.Pal.CertificateExtensionsCommon.GetPrivateKey[T](X509Certificate2 certificate, Predicate1 matchesConstraints) [auth-server_41eb61d1-e]: at System.Security.Cryptography.X509Certificates.RSACertificateExtensions.GetRSAPrivateKey(X509Certificate2 certificate) [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.Tokens.X509SecurityKey.get_PrivateKey() [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.Tokens.X509SecurityKey.get_PrivateKeyStatus() [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.Tokens.AsymmetricSignatureProvider.FoundPrivateKey(SecurityKey key) [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.Tokens.AsymmetricSignatureProvider..ctor(SecurityKey key, String algorithm, Boolean willCreateSignatures) [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.Tokens.AsymmetricSignatureProvider..ctor(SecurityKey key, String algorithm, Boolean willCreateSignatures, CryptoProviderFactory cryptoProviderFactory) [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.Tokens.CryptoProviderFactory.CreateSignatureProvider(SecurityKey key, String algorithm, Boolean willCreateSignatures, Boolean cacheProvider) [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.Tokens.CryptoProviderFactory.CreateForSigning(SecurityKey key, String algorithm, Boolean cacheProvider) [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.Tokens.CryptoProviderFactory.CreateForSigning(SecurityKey key, String algorithm) [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.JsonWebTokens.JwtTokenUtilities.CreateEncodedSignature(String input, SigningCredentials signingCredentials) [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.CreateTokenPrivate(JObject payload, SigningCredentials signingCredentials, EncryptingCredentials encryptingCredentials, String compressionAlgorithm, IDictionary
2 additionalHeaderClaims, String tokenType)
[auth-server_41eb61d1-e]: at Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.CreateToken(SecurityTokenDescriptor tokenDescriptor)
[auth-server_41eb61d1-e]: at OpenIddict.Server.OpenIddictServerHandlers.GenerateIdentityModelAccessToken.HandleAsync(ProcessSignInContext context)
[auth-server_41eb61d1-e]: at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context)
[auth-server_41eb61d1-e]: at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context)
[auth-server_41eb61d1-e]: at OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandler.SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties)
[auth-server_41eb61d1-e]: [19:51:36 INF] Executed action Volo.Abp.OpenIddict.Controllers.TokenController.HandleAsync (Volo.Abp.OpenIddict.AspNetCore) in 256.9522ms
[auth-server_41eb61d1-e]: [19:51:36 INF] Executed endpoint 'Volo.Abp.OpenIddict.Controllers.TokenController.HandleAsync (Volo.Abp.OpenIddict.AspNetCore)'
[auth-server_41eb61d1-e]: [19:51:36 DBG] Added 0 entity changes to the current audit log
[auth-server_41eb61d1-e]: [19:51:36 DBG] Added 0 entity changes to the current audit log
[auth-server_41eb61d1-e]: [19:51:36 DBG] Added 0 entity changes to the current audit log
[auth-server_41eb61d1-e]: [19:51:36 ERR] An unhandled exception has occurred while executing the request.
[auth-server_41eb61d1-e]: Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: Keyset does not exist
[auth-server_41eb61d1-e]: at System.Security.Cryptography.CngKey.Open(String keyName, CngProvider provider, CngKeyOpenOptions openOptions)
[auth-server_41eb61d1-e]: at System.Security.Cryptography.CngKey.Open(String keyName, CngProvider provider)
[auth-server_41eb61d1-e]: at Internal.Cryptography.Pal.CertificatePal.GetPrivateKey[T](Func2 createCsp, Func
2 createCng)
[auth-server_41eb61d1-e]: at Internal.Cryptography.Pal.CertificatePal.GetRSAPrivateKey()
[auth-server_41eb61d1-e]: at Internal.Cryptography.Pal.CertificateExtensionsCommon.GetPrivateKey[T](X509Certificate2 certificate, Predicate1 matchesConstraints) [auth-server_41eb61d1-e]: at System.Security.Cryptography.X509Certificates.RSACertificateExtensions.GetRSAPrivateKey(X509Certificate2 certificate) [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.Tokens.X509SecurityKey.get_PrivateKey() [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.Tokens.X509SecurityKey.get_PrivateKeyStatus() [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.Tokens.AsymmetricSignatureProvider.FoundPrivateKey(SecurityKey key) [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.Tokens.AsymmetricSignatureProvider..ctor(SecurityKey key, String algorithm, Boolean willCreateSignatures) [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.Tokens.AsymmetricSignatureProvider..ctor(SecurityKey key, String algorithm, Boolean willCreateSignatures, CryptoProviderFactory cryptoProviderFactory) [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.Tokens.CryptoProviderFactory.CreateSignatureProvider(SecurityKey key, String algorithm, Boolean willCreateSignatures, Boolean cacheProvider) [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.Tokens.CryptoProviderFactory.CreateForSigning(SecurityKey key, String algorithm, Boolean cacheProvider) [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.Tokens.CryptoProviderFactory.CreateForSigning(SecurityKey key, String algorithm) [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.JsonWebTokens.JwtTokenUtilities.CreateEncodedSignature(String input, SigningCredentials signingCredentials) [auth-server_41eb61d1-e]: at Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.CreateTokenPrivate(JObject payload, SigningCredentials signingCredentials, EncryptingCredentials encryptingCredentials, String compressionAlgorithm, IDictionary
2 additionalHeaderClaims, String tokenType)
[auth-server_41eb61d1-e]: at Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.CreateToken(SecurityTokenDescriptor tokenDescriptor)
[auth-server_41eb61d1-e]: at OpenIddict.Server.OpenIddictServerHandlers.GenerateIdentityModelAccessToken.HandleAsync(ProcessSignInContext context)
[auth-server_41eb61d1-e]: at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context)
[auth-server_41eb61d1-e]: at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context)
[auth-server_41eb61d1-e]: at OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandler.SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Authentication.AuthenticationService.SignInAsync(HttpContext context, String scheme, ClaimsPrincipal principal, AuthenticationProperties properties)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeResultAsync>g__Logged|22_0(ResourceInvoker invoker, IActionResult result)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeResultFilters>g__Awaited|28_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
[auth-server_41eb61d1-e]: at Volo.Abp.AspNetCore.Auditing.AbpAuditingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
[auth-server_41eb61d1-e]: at Volo.Abp.AspNetCore.Auditing.AbpAuditingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
[auth-server_41eb61d1-e]: --- End of stack trace from previous location ---
[auth-server_41eb61d1-e]: at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
[auth-server_41eb61d1-e]: at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
[auth-server_41eb61d1-e]: at Volo.Abp.AspNetCore.Uow.AbpUnitOfWorkMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
[auth-server_41eb61d1-e]: --- End of stack trace from previous location ---
[auth-server_41eb61d1-e]: at Volo.Abp.AspNetCore.ExceptionHandling.AbpExceptionHandlingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
[auth-server_41eb61d1-e]: at Volo.Abp.AspNetCore.ExceptionHandling.AbpExceptionHandlingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
[auth-server_41eb61d1-e]: --- End of stack trace from previous location ---
[auth-server_41eb61d1-e]: at Volo.Abp.AspNetCore.Serilog.AbpSerilogMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
[auth-server_41eb61d1-e]: --- End of stack trace from previous location ---
[auth-server_41eb61d1-e]: at Volo.Abp.AspNetCore.MultiTenancy.MultiTenancyMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
[auth-server_41eb61d1-e]: --- End of stack trace from previous location ---
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Builder.ApplicationBuilderAbpOpenIddictMiddlewareExtension.<>c__DisplayClass0_0.<<UseAbpOpenIddictValidation>b__0>d.MoveNext()
[auth-server_41eb61d1-e]: --- End of stack trace from previous location ---
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
[auth-server_41eb61d1-e]: at Prometheus.HttpMetrics.HttpRequestDurationMiddleware.Invoke(HttpContext context)
[auth-server_41eb61d1-e]: at Prometheus.HttpMetrics.HttpRequestCountMiddleware.Invoke(HttpContext context)
[auth-server_41eb61d1-e]: at Prometheus.HttpMetrics.HttpInProgressMiddleware.Invoke(HttpContext context)
[auth-server_41eb61d1-e]: at Volo.Abp.AspNetCore.Security.AbpSecurityHeadersMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
[auth-server_41eb61d1-e]: --- End of stack trace from previous location ---
[auth-server_41eb61d1-e]: at Volo.Abp.AspNetCore.Tracing.AbpCorrelationIdMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
[auth-server_41eb61d1-e]: --- End of stack trace from previous location ---
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
[auth-server_41eb61d1-e]: --- End of stack trace from previous location ---
[auth-server_41eb61d1-e]: at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
[auth-server_41eb61d1-e]: [19:51:36 INF] Request finished HTTP/2 POST https://localhost:44322/connect/token application/x-www-form-urlencoded 381 - 500 - text/plain;+charset=utf-8 340.6077mshi I sent
hi. We faced a strange issue. steps for reproduce:
just for inform we are not using tenant at all
Do you have any idea?
Hi,
You can try:
public sealed class SampleAppService_Tests : IdentityServiceDomainTestBase { private readonly IUserAppService _userAppService; private ISettingManagementStore _abpSettingStore; protected override void BeforeAddApplication(IServiceCollection services) { _abpSettingStore = Substitute.For<ISettingManagementStore>(); services.AddSingleton(_abpSettingStore); base.BeforeAddApplication(services); } public SampleAppService_Tests() { _userAppService = GetRequiredService<IUserAppService>(); } [Fact] public async Task Test() { var test = await _userAppService.CreateUser(new UserCreateInput() { UserName = "TestUserName", Email = "test@test.com" }, ERole.External); } }
If I IdentityServiceDomainTestBase I can test only managers. But I need to test applications services.
If I use IdentityServiceDomainTestBase
I got another error:
`Autofac.Core.Registration.ComponentNotRegisteredException: The requested service 'AMSuisse.IdentityService.Interfaces.User.IUserAppService' has not be...
Autofac.Core.Registration.ComponentNotRegisteredException The requested service 'AMSuisse.IdentityService.Interfaces.User.IUserAppService' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.`
hi, Why should we use IdentityServiceDomainTestBase for application layer tests?
Hi,
Could you provide the full steps to reproduce the problem? thanks.
I have create a new (first) test in identity microservice
public sealed class SampleAppService_Tests : IdentityServiceApplicationTestBase
{
private readonly IUserAppService _userAppService;
private ISettingManagementStore _abpSettingStore;
protected override void BeforeAddApplication(IServiceCollection services)
{
_abpSettingStore = Substitute.For<ISettingManagementStore>();
services.AddSingleton(_abpSettingStore);
base.BeforeAddApplication(services);
}
public SampleAppService_Tests()
{
_userAppService = GetRequiredService<IUserAppService>();
}
[Fact]
public async Task Test()
{
var test = await _userAppService.CreateUser(new UserCreateInput()
{
UserName = "TestUserName",
Email = "test@test.com"
}, ERole.External);
}
}
And got this error
Autofac.Core.DependencyResolutionException: An exception was thrown while activating Volo.Abp.Settings.DefaultValueSettingValueProvider -> Volo.Abp.SettingManagement.SettingStore -> Volo.Abp.SettingManagement.SettingManagementStore. ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Volo.Abp.SettingManagement.SettingManagementStore' can be invoked with the available services and parameters: Cannot resolve parameter 'Volo.Abp.SettingManagement.ISettingRepository settingRepository' of constructor 'Void .ctor(Volo.Abp.SettingManagement.ISettingRepository, Volo.Abp.Guids.IGuidGenerator, Volo.Abp.Caching.IDistributedCache
1[Volo.Abp.SettingManagement.SettingCacheItem], Volo.Abp.Settings.ISettingDefinitionManager)'.`
Hi. I have problem with testing of Identity microservice. I got an issue .Reflection.DefaultConstructorFinder' on type 'Volo.Abp.SettingManagement.SettingManagementStore' can be invoked with the available services and parameters: Cannot resolve parameter 'Volo.Abp.SettingManagement.ISettingRepository settingRepository' of constructor 'Void .ctor(Volo.Abp.SettingManagement.ISettingRepository, Volo.Abp.Guids.IGuidGenerator, Volo.Abp.Caching.IDistributedCache`1[Volo.Abp.SettingManagement.SettingCacheItem], Volo.Abp.Settings.ISettingDefinitionManager)'.
But in another microservice I did not get this issue. For exapmle in another microservice we mock settings: and when we mock our settings manager:
But in identity microservice it is not working and I do not understand what is wrong
How we can fix the problem? please help