My C# application cannot connect to a url in our company network due to SSL certificate over-write. How can fix it?
I've one web application running on two separate servers and each bound to different subdomain. Something like;
- Application: WebApp , Server: 1.2.3.4 , Hostname: a.myapp.com
- Application: WebApp , Server: 5.6.7.8 , Hostname: b.myapp.com
Normally, my local C# app can interact with both of the servers via subdmoain without any issues. However, when the PC is connected to company network ,the local C# app can connect to the web app bound to subdomain a.myapp.com while it cannot connect to the web app running on b.myapp.com(receiving timeout error). I assume it is because company over writes existing SSL certificate and injects its own SSL certificate.
Note that , I can connect via browsers(chrome and IE) without any issue.
So far I've tried;
ServicePointManager
.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true;
and
var handler = new HttpClientHandler()
{
ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; }
};
var client = new HttpClient(handler);
did not work.
The question is , how come browsers can connect without any issues but System.Net.Http.HttpClient receives timeout ? Is there any way to mimic browser certificate flow in HttpClient?