0

I Create a HttpClient and send a request web to web and I got this exception

"The SSL connection could not be established"

this code bypass the exception but I dont want to use this trick on production.

UseDefaultCredentials = true;
ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; };

When I use refit interface for api I dont get any exception, I need to request web to web too. Why I get this exception how could I establish SSL?

Bunyamin Aslan
  • 193
  • 1
  • 11
  • I did not understand "_When I use refit interface_". Check this [related question](https://stackoverflow.com/questions/44953894/how-can-you-verify-validity-of-an-https-ssl-certificate-in-net), looks like it could help you. Personal note: I do totally agree on not using that into production ;-) – Cleptus May 13 '20 at 09:00
  • Use a sniffer like wireshark or fiddler and compare headers in the first request with working and non working code. Make the headers in c# like headers in working app. The default headers in c# are different. – jdweng May 13 '20 at 10:01
  • Are you on a Azure Linux app service plan? If so, it could be that the OpenSSL layer rejects the connection because your certificate is too weak. – Métoule May 13 '20 at 12:01
  • @Métoule I use windows server my application on iis – Bunyamin Aslan May 18 '20 at 10:48
  • @bradbury9 no there is a no solution in there, I guess my problem is different thnx – Bunyamin Aslan May 18 '20 at 10:50

0 Answers0