开发者

Validate certificate for single HttpWebRequest

I'm developing a utility library that is to be integrated into potentially quite large applicati开发者_JS百科ons. One of the purposes of this library is to contact a central server using https communication. I would like to handle the ssl certificate validation for this call (potentially just accepting any certificate from this central server) but I ONLY want to do validating for this single request.

As far as I can tell there is a static validation callback for such validation:

ServicePointManager.ServerCertificateValidationCallback

I could explicitly specify a delegate from my utility library or hookup an event to the delegate, but this essentially hooks my into the validation process for the entire application and I really only want to validate the certificate for my specific HttpWebRequest.

Is there a way to hook into the certificate validation pipeline for only my specific request?


You can create a new appdomain from your library. then, inside that appdomain, launch a request to the target server using the custom certification callback that you have. This will make sure that other requests running in other appdomains do not get your cert callback implementation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜