Cannot access https url from c# code. trying to access a https://blabla url and access the get method. this is SOAP generated c# class from wsdl. it works from SOAP UI without any problem but doesn't work from the code.i get the error as "Could not create SSL/TLS secure channel"
I've had this so many times.
You need to set the SecurityProtocol
before executing the method. The HTTP Request you are trying to make expects the request to be sent using Transport Layer Security.
To support TLS in your request, use the following code (this sets it to Tls 1.2) before firing the HTTP Request:
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
You can find more information on the different settings from this URL: https://learn.microsoft.com/en-us/dotnet/api/system.net.securityprotocoltype?view=netcore-3.0
If you find that this enum does not exist (because you are using an older version of .NET), you can use the enum integer value from the link above. This example supports Tls 1.2.
System.Net.ServicePointManager.SecurityProtocol = (System.Net.SecurityProtocolType)3072;