开发者

Validate certificate for single HttpWebRequest

开发者 https://www.devze.com 2023-02-12 22:27 出处:网络
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 commun

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

精彩评论

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