.NET HttpWebRequest HTTPS Error

David Fernández picture David Fernández · Jan 16, 2010 · Viewed 12.2k times · Source

Hello I'm trying to fetch data from a https web (i'm not behind firewall or proxy) however even accepting all certificates it keeps throwing System.Net.WebExceptionStatus.SecureChannelFailure with the message shown: Cancelled the request: Unable to create a secure SSL/TLS channel ... i've looked everywhere so you guys are my last chance.

   static void Main(string[] args)
            {
                RemoteCertificateValidationCallback ServerCertificateValidationCallback = delegate { return true; };
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://miyoigo.yoigo.com");
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                {
                    Console.Write(reader.ReadToEnd());
                }
            }

Thanks in advance ;)

Answer

jspcal picture jspcal · Jan 16, 2010

try printing the InnerException property of the WebException, should provide a particular reason the negot failed

Console.WriteLine("Inner Exception");
Console.WriteLine(String.Concat(e.InnerException.StackTrace, e.InnerException.Message));