Reputation: 15850
I have a multi-threaded application that calls a number of URL's from Parallel.ForEach loop. For some of those URL's I need to ignore bad certificates for some I should not.
ServicePointManager.ServerCertificateValidationCallback seems to provide global handling of all certificate validation callbacks.
Can anyone give a suggestion on how I can selectively accept bad certificates in a mutli-threaded Parallel.ForEach() call?
Upvotes: 2
Views: 580
Reputation: 872
It seems like the best way to do this is to make a HashSet of URL's to ignore. If the url isn't something in your set of url's to ignore, then you can deal with bad certificates.
private Hashset<string> UrlWhiteList
...
private bool shouldIgnore(string url){
return UrlWhiteList.Contains(url);
}
Upvotes: 1