8

I don't know if I have all the information needed to phrase this question well, so bear with me.

I have a local web page (local meaning 192.168.*) that is protected with a self-signed SSL cert. I'm trying to access this page using a System.Net.HttpWebRequest object, but I'm running into a weird problem.

If this page is accessed in Internet Explorer with the "Use SSL 2.0" option turned off, the browser returns back an error as if it can't establish a connection. (In other words, a browser connection error, as opposed to a server-sent error.) If the "Use SSL 2.0" option is turned on, the page works fine and you get the standard warning that this is a self-signed cert, do you want to continue, etc. (Oddly enough, Firefox, which supposedly does not have SSL 2.0 turned on, works just fine.)

Now my problem is that I'm trying to access this page with an HttpWebRequest object and the error it's returning back is that the connection has been unexpectedly closed, just like the error IE throws when "Use SSL 2.0" is turned off. (I already have code in place to ignore the fact that it's a self-signed cert, but it's not even getting that far.)

How do I get the System.Net.HttpWebRequest to, well, "Use SSL 2.0" when it's making its request?

1 Answer 1

16

I've hit this issue myself when dealing with Ssl3, though I'm not sure if the same advice would work for SSL2?

To work around the issue I set the Ssl3 flag on the security protocol like so:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

Check out these links for more details:

system.net.servicepointmanager.securityprotocol on MSDN

security protocol enumeration on MSDN

They might point you in the right direction if you're lucky :)

4
  • That was it! As soon as I set it explicitly to SSL3, it worked. Thanks! Commented Oct 4, 2008 at 8:44
  • Thanks so much. Using System.Diagnostics to turn tracing on for System.Net gave me these logs 'System.Net Information: 0 : [16212] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=AlgorithmMismatch). System.Net Error: 0 : [16212] Exception in HttpWebRequest#49844091:: - The request was aborted: Could not create SSL/TLS secure channel.. System.Net Error: 0 : [16212] Exception in HttpWebRequest#49844091::GetResponse - The request was aborted: Could not create SSL/TLS secure channel.. '
    – barthoda
    Commented Jan 21, 2013 at 3:14
  • Setting SecurityProtocol seems also to be a good fix to this tricky issue : blogs.msdn.com/b/fiddler/archive/2012/03/29/… which I'm currently experiencing.
    – AFract
    Commented Dec 19, 2013 at 15:51
  • FWIW, "AlgorithmMismatch" means the server is probably hitting this: blogs.msdn.com/b/ieinternals/archive/2009/12/08/…
    – EricLaw
    Commented Sep 10, 2014 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.