In the process of updating my project from 11.4 to 13.0.0, I encountered a problem in generating service-proxies with nswag. I have tried returning to my project @ 11.4, but I am still getting an error, so I can't attribute the problem to the upgrade process. As before this upgrade, i had not had changes to my API requiring regeneration of service proxies for several months, I don't have any comparison point recently that I can say the generation process worked.
Whenever I try running nswag (using refresh.bat), I am getting the exception below. Searching for possible solutions, I tried regenerating the development certificates with
dotnet dev-certs https --clean
dotnet dev-certs https
dotnet dev-certs https --trust
with no success. I've also run nswag specifying runtime of .net 6.0 and .net 7.0 with no success. (.net 6.0 was original level when using ANZ 11.4).
To further complicate, my Windows configuration has updated numerous times over the past several months, and I"m running at Windows 10 22H2.
I'm looking for any suggestions on how to resolve this so I can finish the angular piece of my update. Has anyone else seen this problem, even in a different context?
Executing file 'C:\Users\micha\source\repos\NexusApps\angular\nswag\service.config.nswag' with variables ''... System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid because of errors in the certificate chain: NotTimeValid at System.Net.Security.SslStream.SendAuthResetSignal(ProtocolToken message, ExceptionDispatchInfo exception) at System.Net.Security.SslStream.CompleteHandshake(SslAuthenticationOptions sslAuthenticationOptions) at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm) at System.Net.Security.SslStream.ProcessAuthenticationWithTelemetryAsync(Boolean isAsync, Boolean isApm, CancellationToken cancellationToken) at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(HttpRequestMessage request) at System.Threading.Tasks.TaskCompletionSourceWithCancellation
1.WaitWithCancellationAsync(CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.AuthenticationHelper.SendWithAuthAsync(HttpRequestMessage request, Uri authUri, Boolean async, ICredentials credentials, Boolean preAuthenticate, Boolean isProxyAuth, Boolean doRequestAuth, HttpConnectionPool pool, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async,
CancellationToken cancellationToken)
at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
at CallSite.Target(Closure , CallSite , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at NJsonSchema.Infrastructure.DynamicApis.HttpGetAsync(String url, CancellationToken cancellationToken)
at NSwag.OpenApiDocument.FromUrlAsync(String url, CancellationToken cancellationToken) in //src/NSwag.Core/OpenApiDocument.cs:line 234
at NSwag.Commands.Generation.FromDocumentCommand.RunAsync() in //src/NSwag.Commands/Commands/Generation/FromDocumentCommand.cs:line 62
at NSwag.Commands.Generation.FromDocumentCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in //src/NSwag.Commands/Commands/Generation/FromDocumentCommand.cs:line 53
at NSwag.Commands.NSwagDocumentBase.GenerateSwaggerDocumentAsync() in //src/NSwag.Commands/NSwagDocumentBase.cs:line 275
at NSwag.Commands.NSwagDocument.ExecuteAsync() in //src/NSwag.Commands/NSwagDocument.cs:line 81
at NSwag.Commands.Document.ExecuteDocumentCommand.ExecuteDocumentAsync(IConsoleHost host, String filePath) in //src/NSwag.Commands/Commands/Document/ExecuteDocumentCommand.cs:line 85
at NSwag.Commands.Document.ExecuteDocumentCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in //src/NSwag.Commands/Commands/Document/ExecuteDocumentCommand.cs:line 48
at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object input)
at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input)
at NSwag.Commands.NSwagCommandProcessor.ProcessAsync(String[] args) in //src/NSwag.Commands/NSwagCommandProcessor.cs:line 61node:child_process:965
throw err;
^
Error: Command failed: dotnet "C:\Users\micha\source\repos\NexusApps\angular\node_modules\nswag\bin/binaries/Net60/dotnet-nswag.dll" run /runtime:Net60 at checkExecSyncError (node:child_process:890:11) at Object.execSync (node:child_process:962:15) at C:\Users\micha\source\repos\NexusApps\angular\node_modules\nswag\bin\nswag.js:63:19 at ChildProcess.exithandler (node:child_process:414:7) at ChildProcess.emit (node:events:518:28) at maybeClose (node:internal/child_process:1105:16) at Socket.<anonymous> (node:internal/child_process:457:11) at Socket.emit (node:events:518:28) at Pipe.<anonymous> (node:net:337:12) { status: 4294967295, signal: null, output: [ null, null, null ], pid: 684, stdout: null, stderr: null }`
2 Answer(s)
-
0
Hi @michael.pear
Could you try this https://stackoverflow.com/a/73415543 ?
-
0
I wasn't able to find a folder ASP.NET in %AppData%, however, searching for other information on certificates for localhost, I finally found the problem. It appears that a certificate for "localhost" on my development system (virtual machine) had expired (4/3/24). A symptom that this had occurred was a warning message in the MIcrosoft Edge browser that my https//localhost: connection was not private when I started IIExpress from Visual Studio. The expiration date was 5 yrs after I initially setup my development environment for ASPNET Zero.
I was able to get things working with the following steps:
- Using "certmgr", delete the expired certificate for localhost from "Personal/Certificates".
- "Repair" IIExpress to generate a new certificate for localhost. (See https://stackoverflow.com/questions/20036984/how-do-i-restore-a-missing-iis-express-ssl-certificate)
- Delete the applicationhost.config file in the .vs folder of your project directory, and do a Clean/Build to restore it. Browser should now come up with no err when you start the debugger (see https://stackoverflow.com/questions/37352603/localhost-refused-to-connect-error-in-visual-studio).
Now, when I run nswag, everything generates normally.
So long term users, who may not have replaced their development systems or virtual machines and just updated them, you may run into your original development certificate expiring!