C# WebRequest - "The request was aborted: Could not create SSL/TLS secure channel."

  • Thread starter Thread starter Melvin Hung
  • Start date Start date
M

Melvin Hung

Guest
Hi All,

Below curl request working fine but when i convert this request in c# web request then i got error.

//To Solve the SSL/TLS secure channel
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11;
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);

System.Net.WebProxy myProxy = new System.Net.WebProxy();

Uri newUri = new Uri("http://xxx:8080");
myProxy.Address = newUri;
myProxy.Credentials = CredentialCache.DefaultNetworkCredentials;
request.Proxy = myProxy;
request.Credentials = CredentialCache.DefaultNetworkCredentials;
request.PreAuthenticate = true;
HttpWebResponse myWebResponse = (HttpWebResponse)request.GetResponse();

---

config file .net Framework

<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>

---

Error Detail:
The request was aborted: Could not create SSL/TLS secure channel.
error in below line
HttpWebResponse myWebResponse = (HttpWebResponse)request.GetResponse();

---

also i have tried with postman and its working fine with "postman tools" and curl as well. only issue i use web request.

Continue reading...
 
Back
Top