views:

342

answers:

4

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 ;)

A: 

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));
jspcal
InnerException is null
Luffy
The Message tells me is something like (translated): Cancelled the request: Unable to create a secure SSL/TLS channel
Luffy
A: 

That code works fine for me exactly as you have it. My guess is that you've got something network related going on. Are you behind a proxy or firewall? Like Ray said in his comment, try hitting that URL from a browser.

squillman
i'm connected directly to the router
Luffy
A: 

Get a tracelog of the application (see System.Net tracing) and see why the SSL hanshake is failing.

feroze
thanks, it is failing due to AlgorithmMismatch, but i don't know how to fix it
Luffy
i've check with other https sites and they work well and their certificate is similar to this
Luffy
What is the algorithm mismatch? Can you show the exact message snippet from the log?
feroze
This are the last twoSystem.Net Information: 0 : [2424] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = 1bed9d10:1e8a380, targetName = miyoigo.yoigo.com, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)System.Net Information: 0 : [2424] InitializeSecurityContext(Number of In-Buffers=2, Length of Out-Buffer=0, return code=AlgorithmMismatch).
Luffy
Can you put the logfile on pastebin.com? I would like to see why you are getting this, and it involves looking at how the connection was established, etc.On searching, I found this article http://www.derkeiler.com/Newsgroups/microsoft.public.platformsdk.security/2004-06/0245.html which seems to imply that there is a disconnect in the algorithms supported between server and client.Exact details can only be found by looking at the log.
feroze
http://pastebin.com/m657613c0 though some info is in my system language spanish, hope it helps ;)
Luffy
Hmm. logfile doesnt show anything useful. I used WebClient to go to the same server from my WinXP/SP3 desktop, and it passed. At this point I am at a loss. You probably need lower level logging at the Schannel level to figure out why the algorithms are not matching up.
feroze
What platform are you using? If you are on Vista or Windows7 you should be able to enable ETL tracing for schannel and see why the SSL handshake failed.
feroze
Thanks for your effort to help me ;) The Two Messages (error events) are:A request of SSL 3.0 connection was received from a remote client application, but none of sets of compatible encryption applications of client is compatible with the server. Error at the SSL connection request.It was generated the following unrecoverable warning: 40. The internal error state is 107
Luffy
How did you see this? Is this something logged in the eventlog? Or are you getting it from the schannel trace? If so, can you post the full text on pastebin?
feroze
I have seen this opening the etl with the event log viewer, this file was generated tracing the schannel provider using netsh(netsh trace start provider=schannel level=4) while executing the .net apphere it is the .etl: http://www.megaupload.com/?d=EINO8NEF
Luffy
How did you view this ETL file? I cannot get a decent output using tracerpt.exe.You could also try the following technique on your machine http://support.microsoft.com/kb/260729. This will cause schannel to log to the eventlog.
feroze
As i told you i've seen it importing using the event viewer... i already used the most informational level... and what i see here it's just but i already got :S
Luffy