RestSharp - Ignore SSL errors

后端 未结 3 1940
灰色年华
灰色年华 2020-12-07 22:00

Is there any whay that I can get RestSharp to ignore errors in SSL certificates? I have a test client, and the service I connect to does not yet have a valid cetificate.

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-07 22:27

    You can bypass ssl check

    In object level:

    (available in RestSharp v106.0.0 and later)

    //bypass ssl validation check by using RestClient object
    var restClient = new RestClient(baseUrl);
    restClient.RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;
    

    OR

    In application level:

    //bypass ssl validation check globally for whole application.
    ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
    

提交回复
热议问题