In c# I am able to set a static value for SSL3 or TLS, e.g.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
Or:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
But (I believe) this will affect all future HttpWebRequest objects in my application.
Is there a way to set this for a given HttpWebRequest or at least for a given URI?
Note I have seen this:
Uri uri = new Uri(url);
ServicePoint sp = ServicePointManager.FindServicePoint(uri);
But ServicePoint does not have a SecurityProtocol property.
At present I am thinking I will have to just set the static global property prior to creating a new HttpWebRequest.
This doesn't feel right and it also means:
- I have to make sure multiple threads are not doing this at the same time.
- I am not sure by what point this setting has been 'used' (i.e. is it when I call webRequest.GetResponse() that the ServicePointManager.SecurityProtocol is accessed and bound to that URI?).