Reputation: 47
I have an asp.net core 2.2 Angular 11 project going well and now I don't know why I get the error "The SSL connection could not be established" on my queries.
I created an ASP.net core 5 Web API project (without angular and without view) to separate Angular from .net. But the problem remains the same. I've been working on this error for a week, I tried everything I could find on the internet around this issue but always the same problem.
Below I put the complete error after having launched the request via Postman.
I'm in local under windows 10.
HttpClientHandler clientHandler = new HttpClientHandler();
clientHandler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; };
client = new HttpClient(clientHandler);
Task<HttpResponseMessage> reponse = client.PostAsJsonAsync(url, user);
var result = reponse.Result.Content.ReadFromJsonAsync<Result<User>>().Result;
the error :
System.AggregateException: One or more errors occurred. (The SSL connection could not be established, see inner exception.)\r\n ---> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.\r\n ---> System.IO.IOException: Cannot determine the frame size or a corrupted frame was received.\r\n at System.Net.Security.SslStream.ReceiveBlobAsync[TIOAdapter](TIOAdapter adapter)\r\n at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)\r\n at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Boolean async, Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)\r\n --- End of inner exception stack trace ---\r\n at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Boolean async, Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)\r\n at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)\r\n at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpClient.SendAsyncCore(HttpRequestMessage request, HttpCompletionOption completionOption, Boolean async, Boolean emitTelemetryStartStop, CancellationToken cancellationToken)\r\n --- End of inner exception stack trace ---\r\n at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)\r\n at System.Threading.Tasks.Task.Wait()\r\n at FlytaggerWebApi.Controllers.CommandController.setCampagne(Campagne campagne) in userController.cs:line 455
Upvotes: 4
Views: 10202
Reputation: 47
I figured out what was wrong and it's normal that everything I tried had no effect.
I divided my application into several projects. There is a RESTFULL API project (which I call business application) that has no external access and queries the database and the website or mobile application can't call this project directly.
For this, I created another web api project (that I call process) to make the link between the 2. Everything was working fine until the error mentioned above.
I just created a new table and thus a new controller in the business application and the error only occurs when I call the functions of this new controller. All other calls work without any problem (when the process calls the business application, I have no problems except when it calls the new controller).
So I look at what's wrong with this controller, what's different with the other controllers that are working.
Upvotes: -1