zoukankan      html  css  js  c++  java
  • 调用含有header的WebService时,跳过证书验证

      最近在做Webservice的接口调用,header的用户名和密码都是正确的,地址也是对的,但一直提示:基础连接已关闭,未能与SSL/TLS安全通道建立信任关系。

    解决方案:

    请求之前加上下面得代码即可,简洁实用

    1.

    ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;

    2.

    ServicePointManager.ServerCertificateValidationCallback = new        
    RemoteCertificateValidationCallback
    (
       delegate { return true; }
    );

    这样做会潜在一定风险

    所有验证都会通过,不论是否证书是无效得。whatever ,还有其他方案? 或者针对特定链接这样做就好了

    1.This will accept all certificates, regardless of why they are invalid, which resolved the customer’s issue.

    By validating the X509 certificate provided by the computer running Microsoft Exchange Server 2007 for SSL over HTTP, you help to provide a layer of security for the client application. You must validate certificates before you can start programming with Exchange Web Services proxy classes. If the callback is not set up, the first call will fail with a certificate error.

    2.This solution could be potential security threat as you are turning off the SSL certificate validation. If this is production code, understand the risk of the server you are connecting to.

    原文地址:https://www.cnblogs.com/miralce/p/4773037.html

  • 相关阅读:
    Select2插件的隐藏、设置宽度
    远程登陆Linux服务器
    ECMAScript typeof用法
    Select2异步搜索数据
    ECMAScript 引用类型
    LeetCode 任务调度器-Python3<八>
    sort、sorted高级排序-Python3.7 And 算法<七>
    LeetCode算法笔记目录
    数据结构-Python3.7<三>
    【夯实PHP基础】php开发时遇到白页的调试方法
  • 原文地址:https://www.cnblogs.com/zyl1994/p/8386594.html
Copyright © 2011-2022 走看看