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?
UPDATE 1-6-2022:
OK - This is weird but everything seemingly got fixed overnight on their end. Code works just fine now. Maybe they introduced a bad cipher and I just happened to run into it exactly on the day they were fixing it but I have no problems this morning. Seems like a big coincidence but at least good folks like @Julian helped me know that I'm not crazy.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.