microsoft / IIS.Administration

REST API for managing IIS
Other
500 stars 140 forks source link

500 Internal server error, unable to login #315

Open umardraz opened 1 year ago

umardraz commented 1 year ago

Hi,

I have installed IIS Administration 6.0.0. on server 2016.

I had successfully generated Access Token But I am getting 500 internal server error whenever I tried API explorer using https://localhost:55539/#/api

Here is the event error logs

Log Name: Application Source: Microsoft IIS Administration API Date: 11/20/2022 11:28:22 PM Event ID: 0 Task Category: None Level: Error Keywords: Classic User: N/A Computer: udf-zlb-04 Description: Microsoft IIS Administration API encountered an unexpected error: System.ArgumentOutOfRangeException: The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset') at System.DateTimeOffset.ValidateDate(DateTime dateTime, TimeSpan offset) at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync() at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync() at Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.AuthenticateAsync() at Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync(HttpContext context, String scheme) at Microsoft.AspNetCore.Authorization.Policy.PolicyEvaluator.AuthenticateAsync(AuthorizationPolicy policy, HttpContext context) at Microsoft.AspNetCore.Mvc.Authorization.AuthorizeFilter.OnAuthorizationAsync(AuthorizationFilterContext context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) at Microsoft.IIS.Administration.WebServer.Injector.Invoke(HttpContext context) at Microsoft.IIS.Administration.HeadTransform.Invoke(HttpContext context) at Microsoft.IIS.Administration.Startup.<>c.<b4_0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.IIS.Administration.Security.Authorization.AuthorizationPolicyMiddleware.Invoke(HttpContext context, IAuthorizationService authorizationService) at Microsoft.IIS.Administration.Security.WindowsAuthenticationExtensions.<>c.<b__0_0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.IIS.Administration.Cors.CorsExtensions.<>c.<b0_2>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.IIS.Administration.Cors.CorsExtensions.<>c__DisplayClass0_0.<b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.IIS.Administration.ErrorHandler.Invoke(HttpContext context) Event Xml:

0 2 0 0x80000000000000 1186316 Application udf-zlb-04

Here is the appsettings.json file

{ "host_id": "8b9b1d66-9491-4383-a465-5024fa435a8c", "host_name": "IIS Administration API", "security": { "require_windows_authentication": false, "users": { "administrators": [ "UDF-ZLB-04\Administrator" ], "owners": [ "UDF-ZLB-04\Administrator" ] }, "access_policy": { "api": { "users": "Everyone", "access_key": true }, "api_keys": { "users": "administrators", "access_key": false }, "system": { "users": "owners", "access_key": true } } }, "logging": { "enabled": true, "min_level": "error", "file_name": "log-{Date}.txt", "LogLevel": { "Default": "Error", "System": "Error", "Microsoft": "Error" } }, "auditing": { "enabled": true, "file_name": "audit-{Date}.txt" }, "cors": { "rules": [ { "origin": "https://manage.iis.net", "allow": true } ] } }

dbContext commented 1 year ago

it looks to be because they're using DateTimeOffset with a UTC DateTime so when generating a Forever Token, you're outside bounds IF your local server timezone isn't UTC. I had the same issue with a Forever Token, then updated my timezone to UTC, and worked fine after this.