Search code examples
c#rest-client

How to allow insecure connections using Tiny Rest Client?


I have a site that can connet using https but not http. There is no certificate installed in server, so, when connected using htts, a warning is shown.

If using a browser, I can allow to browse anyway, however, if I use Tiny Rest Client, a certificate not valid exception is thrown.

Is there a way to allow that connection using TinyRestClient? I have not found a way yet.

Thanks


Solution

  • If you inject a new HttpClient that has a custom HttpHandler, you should be able to access any kind of certificate, even self signed

    var handler = new HttpClientHandler()
    {
        ServerCertificateCustomValidationCallback = 
            HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
    };
    var http = new HttpClient(handler);
    
    var client = new TinyRestClient(http, url);