Quantcast
Channel: Visual Studio General Questions forum
Viewing all articles
Browse latest Browse all 21115

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3

$
0
0

VS2008 with Dot Net 3.5

Application is several years old.
There is a dynamic set of outbound connections in multiple threads. 

byte[] bytes = Encoding.ASCII.GetBytes(sd.postdata);
myHttpWebRequest.ContentLength = bytes.Length;
using (Stream oStreamOut = myHttpWebRequest.GetRequestStream())
{
 oStreamOut.Write(bytes, 0, bytes.Length);
 oStreamOut.Close();
}

using (webresponse = (HttpWebResponse)myHttpWebRequest.GetResponse())
{
 ....
}

I now have a new interface to a web server that only supports SecurityProtocolType.Ssl3

      ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

At the same time I have multiple others that only support SecurityProtocolType.Tls

It is my understanding that ServicePointManager.SecurityProtocol is a global setting and will affect every thread. Since the software has potentially hundreds of threads running at the same time, that would cause a collision.

Assuming the above, the only option would be a thread lock while the ssl3 processes ( up to 30 seconds ) and is not an option.

How can I change the SecurityProtocol for just the current connection in the current thread?



Viewing all articles
Browse latest Browse all 21115

Trending Articles