我是靠谱客的博主 威武音响,最近开发中收集的这篇文章主要介绍c# https请求忽略证书验证,什么是用C#处理非验证SSL证书的最佳方式,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

I'm using the following code to make sure all certificates pass, even invalid ones, but I would like to know if there is a better way, as this event gets called globally and I only want the certificate to pass for a certain HTTP call and not for any others that are happening asynchronously.

// This delegate makes sure that non-validating SSL certificates are passed

ServicePointManager.ServerCertificateValidationCallback = delegate(object certsender, X509Certificate cert, X509Chain chain, System.Net.Security.SslPolicyErrors error)

{

return true;

};

The code above is just an example of ignoring any non-validation on the certificate. The problem that I'm having is that it is a global event. I can't see which session the event is happening for. I might have a couple of http requests going through and I want to ask the user for an action for each request.

解决方案

What about the certsender argument? Does it contain anything sensible so that you can tell what connection the callback is happening for? I checked the .NET API but it doesn't say what the argument is supposed to contain...

最后

以上就是威武音响为你收集整理的c# https请求忽略证书验证,什么是用C#处理非验证SSL证书的最佳方式的全部内容,希望文章能够帮你解决c# https请求忽略证书验证,什么是用C#处理非验证SSL证书的最佳方式所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(49)

评论列表共有 0 条评论

立即
投稿
返回
顶部