views:

800

answers:

1

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?

+2  A: 

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 your lucky :)

Bittercoder
That was it! As soon as I set it explicitly to SSL3, it worked. Thanks!
Dylan Bennett
Great good to know it worked :)
Bittercoder