Open Closed

how to create openiddict cert from code automatically whenever cert is about to expire #8681


User avatar
0
priyankasynapxe created

ABP Framework version: v8.1.1

UI Type:React

Database System: EF Core (SQL Server)

Tiered (for MVC) or Auth Server Separated (for Angular): yes

Exception message and full stack trace: NA

Steps to reproduce the issue: NA

Hi,

I'm not able to launch my application suddenly and below is the error in logs

2025-01-22 10:26:22.972 +08:00 [ERR] An unhandled exception has occurred while executing the request.

System.InvalidOperationException: When using X.509 encryption credentials, at least one of the registered certificates must be valid.

To use key rollover, register both the new certificate and the old one in the credentials collection.

   at OpenIddict.Server.OpenIddictServerConfiguration.PostConfigure(String name, OpenIddictServerOptions options)

   at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)

   at Microsoft.Extensions.Options.OptionsMonitor`1.<>c.<Get>b__10_0(String name, IOptionsFactory`1 factory)

   at Microsoft.Extensions.Options.OptionsCache`1.<>c__DisplayClass3_1`1.&lt;GetOrAdd&gt;b__2()

   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)

   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)

   at System.Lazy`1.CreateValue()

   at System.Lazy`1.get_Value()

   at Microsoft.Extensions.Options.OptionsCache`1.GetOrAdd[TArg](String name, Func`3 createOptions, TArg factoryArgument)

   at Microsoft.Extensions.Options.OptionsMonitor`1.Get(String name)

   at Microsoft.Extensions.Options.OptionsMonitor`1.get_CurrentValue()

   at OpenIddict.Validation.ServerIntegration.OpenIddictValidationServerIntegrationConfiguration.Configure(OpenIddictValidationOptions options)

   at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)

   at Microsoft.Extensions.Options.OptionsMonitor`1.&lt;&gt;c.&lt;Get&gt;b__10_0(String name, IOptionsFactory`1 factory)

   at Microsoft.Extensions.Options.OptionsCache`1.&lt;&gt;c__DisplayClass3_1`1.<GetOrAdd>b__2()

   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)

--- End of stack trace from previous location ---

   at System.LazyHelper.ThrowException()

   at System.Lazy`1.CreateValue()

   at System.Lazy`1.get_Value()

   at System.Lazy`1.CreateValue()

   at System.Lazy`1.get_Value()

   at Microsoft.Extensions.Options.OptionsCache`1.GetOrAdd[TArg](String name, Func`3 createOptions, TArg factoryArgument)

   at Microsoft.Extensions.Options.OptionsMonitor`1.Get(String name)

   at Microsoft.Extensions.Options.OptionsMonitor`1.get_CurrentValue()

   at OpenIddict.Validation.OpenIddictValidationFactory.CreateTransactionAsync()

   at OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandler.HandleRequestAsync()

   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)

   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)

   at eFC.Web.eFCWebModule.&lt;&gt;c.&lt;&lt;OnApplicationInitialization&gt;b__14_0>d.MoveNext() in /work/3/747/s/src/src/eFC.Web/eFCWebModule.cs:line 430

--- End of stack trace from previous location ---

   at eFC.Web.eFCWebModule.&lt;&gt;c.&lt;&lt;OnApplicationInitialization&gt;b__14_0>d.MoveNext() in /work/3/747/s/src/src/eFC.Web/eFCWebModule.cs:line 430

--- End of stack trace from previous location ---

   at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.&lt;Invoke&gt;g__AwaitMatcher|10_0(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task`1 matcherTask)

   at Volo.Abp.AspNetCore.Tracing.AbpCorrelationIdMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)

   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext()

--- End of stack trace from previous location ---

   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
 

after further analysis I found openiddict cert is expired. Is there any way by which I can create cert from code automatically whenever cert is about to expire?

thanks


3 Answer(s)
  • User Avatar
    0
    alper created
    Support Team Director

    try generating a new certificate, this topic has been discussed at https://abp.io/support/questions/8266/Generating-CRUD-using-abp-suite-for-module#answer-3a163c11-d8c4-b919-6178-9901f37c352e

  • User Avatar
    0
    priyankasynapxe created

    try generating a new certificate, this topic has been discussed at https://abp.io/support/questions/8266/Generating-CRUD-using-abp-suite-for-module#answer-3a163c11-d8c4-b919-6178-9901f37c352e

    I generated using

    dotnet dev-certs https -v -ep openiddict. pfx -p 00000000-0000-0000-0000-000000000000 command to generate the openiddict. pfx certificate

    but I'm looking for solution where I don't need to worry about its expiry, it should generate using code.

  • User Avatar
    0
    alper created
    Support Team Director

    but that's not directly related to ABP. it's a certificate that your hosting uses. you can create a console app and create everytime it expires

Made with ❤️ on ABP v9.2.0-preview. Updated on January 20, 2025, 07:44