I am running into an odd TLS error when using HttpClient in a .NET 6 app. The code is pretty simple and works 99.9% of the time. However, there is one site (ultipro.com) that keeps failing on TLS Handshake. I've looked at their site/certificates and they use TLS1.2 which should be no problem for this version of .NET.
My code:
try { string url; //Examples: These do not work --> SSL Error url = "https://recruiting.ultipro.com/LOS1000LADOD/JobBoard/5365ad6e-23ff-4703-bb77-1e9451fb855e/OpportunityDetail?opportunityId=3b914758-c414-4f1d-a8f2-7d5c0e453cca"; //url = "https://recruiting.ultipro.com/GRA1017GRYT/JobBoard/ae441110-89bd-444d-8ad2-b76c7b9db7a9/OpportunityDetail?opportunityId=acb56de2-b21f-49a1-9c48-7da6d7e47491" //Example: Works fine //url = "https://www.foxcareers.com/Search/JobDetail/R50016539"; using (var client = new HttpClient()) { var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); var response = await client.SendAsync(httpRequestMessage); if (response.IsSuccessStatusCode) { using (var contentStream = await response.Content.ReadAsStreamAsync()) { StreamReader reader = new StreamReader(contentStream, Encoding.GetEncoding("utf-8")); string content = reader.ReadToEnd(); } } else { Console.WriteLine("Internal server Error"); } } } catch (Exception ex) { string errormsg = ex.Message; } The Error:
The SSL connection could not be established, see inner exception. Inner Exception: Authentication failed because the remote party sent a TLS alert: 'HandshakeFailure'. Source: System.Net.Security I've tried everything I can think of including adding/removing different headers and specifying the TLS version. Ex:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; These URLs work just fine in my browser and Postman. Any ideas on what I'm overlooking?