I know there are several threads about this, but I think my case might be different.
Our application needs to send requests to 2 HTTPS URL's: one of them is the ReCaptcha service, and another is some government service from Brazil (if you are from Brazil, probably you know what SEFAZ and NF-e means :D)
Sometimes, both just stops working. The exception, as the title says, is "Could not establish trust relationship for the SSL/TLS secure channel". When one of them starts throwing the exception, the other starts throwing it too, and vice versa: while one of them works, the other works too.
Everything was running just fine until some days ago when this exception started throwing randomly. This exception throws in our production server and also in our internal development server.
So, there are 2 services (ReCaptcha and this governement service) that just stops working apparently at the same time in both servers, apparently randomly. They stop working and then start working again.
The CA root is different in both cases. One uses GeoTrust Global CA and the other uses ICP-Brasil.
Based on this thread, we thought that maybe the clock is wrong, but it apparently isn't. We check it constantly.
I know about this solution:
ServicePointManager.ServerCertificateValidationCallback =
((sender, certificate, chain, sslPolicyErrors) => true);
But it doesn't look very safe for me. Is there a problem using those solutions?
We could also use this:
ServicePointManager.ServerCertificateValidationCallback =
((sender, cert, chain, errors) => cert.Subject.Contains("ServerName"));
But we are really curious about why this exception throws apparently randomly. We might use it if we don't solve it in a "proper" fashion.
So, we ran out of ideas. Our service runs on Windows Server 2008R2 and IIS 7.5. What else should I look for?