0

I Can't send https request by c# I tried to use all answers I found but I am got the same error (could not establish secure channel for ssl/tls ) I added this line of code and it doesn't solve the problem

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Ssl3|SecurityProtocolType.Tls;

but the request work correctly when I use windows 10 but in windows 7 not working although it work in windows 7 if I send request by Fiddler or Postman

Moneim
  • 53
  • 1
  • 5
  • Does this help? [Could not create SSL/TLS secure channel only on Windows Server 2012](https://stackoverflow.com/questions/59975964/could-not-create-ssl-tls-secure-channel-only-on-windows-server-2012) – stuartd Jul 15 '21 at 15:33
  • And have you tried to enable TLS 1.2 [according to the documentation](https://support.microsoft.com/en-us/topic/update-to-enable-tls-1-1-and-tls-1-2-as-default-secure-protocols-in-winhttp-in-windows-c4bd73d2-31d7-761e-0178-11268bb10392)? See also https://www.admin-enclave.com/en/articles/windows/305-enable-tls-1-2-on-windows-2012-r2.html – Charlieface Jul 15 '21 at 19:21

1 Answers1

0

Try this

if (ServicePointManager.SecurityProtocol.HasFlag(SecurityProtocolType.Tls12) == false)
{
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
}
jamheadart
  • 5,047
  • 4
  • 32
  • 63
SRK45
  • 43
  • 5