Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL error in Self-Signed certification #256

Closed
Majidgholipour opened this issue Jan 29, 2023 · 4 comments
Closed

SSL error in Self-Signed certification #256

Majidgholipour opened this issue Jan 29, 2023 · 4 comments
Assignees
Labels
waiting-8-days Closing after 8 days of waiting for the additional info requested.

Comments

@Majidgholipour
Copy link

Describe the bug
I have configured Downstream and Upstream in Https, and also i used Self-Signed certification on test environment. I get the following error when running the gateway:

Category: Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer
EventId: 2
SpanId: 07e87c7b89c4839c
TraceId: a126d298b2c2490422fa92ea6b2f87ea
ParentId: 0000000000000000
RequestId: 800000e7-0001-f400-b63f-84710c7967bb
RequestPath: /swagger/docs/1.0/Order

Connection ID "17582052951159996646", Request ID "800000e7-0001-f400-b63f-84710c7967bb": An unhandled exception was thrown by the application.

Exception:
System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch
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.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.TaskCompletionSourceWithCancellation1.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.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpClient.GetStringAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken) at MMLib.SwaggerForOcelot.Repositories.DownstreamSwaggerDocsRepository.GetSwaggerJsonAsync(RouteOptions route, SwaggerEndPointOptions endPoint, String docsVersion) at MMLib.SwaggerForOcelot.Middleware.SwaggerForOcelotMiddleware.Invoke(HttpContext context, ISwaggerEndPointProvider swaggerEndPointRepository, IDownstreamSwaggerDocsRepository downstreamSwaggerDocs) at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.InvokeCore(HttpContext context, PathString matchedPath, PathString remainingPath) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.MiddlewareAnalysis.AnalysisMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.MiddlewareAnalysis.AnalysisMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT1.ProcessRequestAsync()

@Burgyn
Copy link
Owner

Burgyn commented Jan 31, 2023

Is the problem only with the documentation requirement? Or also when calling endpoints?

@Burgyn Burgyn added the waiting-8-days Closing after 8 days of waiting for the additional info requested. label Jan 31, 2023
@Majidgholipour
Copy link
Author

Occurs when calling endpoints

@github-actions github-actions bot removed the waiting-8-days Closing after 8 days of waiting for the additional info requested. label Feb 5, 2023
@tcsidevtools
Copy link
Contributor

I could be wrong here but I believe this NuGet package doesn't do much when it comes to calling the endpoints. It shows you the documentation and serves the JSON files.

The error you show is a name mismatch. which happens when the self-signed certificate has a common name that does not match the domain name the server is using. The dev certificate which is utilized in asp.net is only assigned localhost as a common name and so any other domain will cause that error.

You should generate a certificate that matches your domain name. and/or use the subject-alternative name on the certificate in the case that you have multiple names the server may go by. I'm unsure if there's another way to do this. But I did do a pull request which allows you to generate a named HTTP client. You can use that to prep an HTTP client with the certificate preloaded for use.

@Burgyn Burgyn added the waiting-8-days Closing after 8 days of waiting for the additional info requested. label Mar 3, 2023
@github-actions
Copy link

github-actions bot commented Mar 3, 2023

Closing after 8 days of waiting for the additional info requested.

@github-actions github-actions bot closed this as completed Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-8-days Closing after 8 days of waiting for the additional info requested.
Projects
None yet
Development

No branches or pull requests

3 participants