Bypass invalid SSL certificate errors when calling web services in .Net

前端 未结 8 882
栀梦
栀梦 2020-11-28 20:33

We are setting up a new SharePoint for which we don\'t have a valid SSL certificate yet. I would like to call the Lists web service on it to retrieve some meta data about th

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 21:08

    Alternatively you can register a call back delegate which ignores the certification error:

    ...
    ServicePointManager.ServerCertificateValidationCallback = MyCertHandler;
    ...
    
    static bool MyCertHandler(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors error)
    {
    // Ignore errors
    return true;
    }
    

提交回复
热议问题