Last post Feb 18, 2020 08:04 AM by nideeshm
Feb 18, 2020 08:04 AM|nideeshm|LINK
Our asp.net core web application which is targeting full framework is access web api over https.
we are using simple System.Net.Http.HttpClient.
It works for some time, then it starts throwing below error message. After restarting the IIS, It works again.
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
at System.Net.PooledStream.EndWrite(IAsyncResult asyncResult)
at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
What could be reason ? Any way to find the root cause? Is it because of socket - port exhaustion ? Is it because of network packets being dropped ?
We have added the certificate of api in trusted root under the computer.
We have also added it to certificate under IIS.
We have checked the certificate domain name and api url.
We have made sure the TLS 1.2 is enabled as Webapi supports only 1.2
The webapi is present in a load balancer.