-3

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

jstuardo
  • 3,901
  • 14
  • 61
  • 136
  • https://letsencrypt.org/ ? Or is this a locally hosted server? Will it be sufficient to use a self-signed certificate? – Fildor Nov 14 '22 at 19:17
  • No.... it is a Web Server embedded inside a device. That is why I asked about doing that using the client, since I cannot modify the server nor installing anything in it. – jstuardo Nov 14 '22 at 19:34
  • Argh, that's too bad. I am not familiar with TinyRestClient, though, sorry. I tend to prefer the "more secure" path. But in this case, you seem to be stuck with plain http. – Fildor Nov 14 '22 at 19:37
  • Funny enough: from their examples - `var client = new TinyRestClient(new HttpClient(), "http://MyAPI.com/api");` (Mind _http_ not _http**s**_) – Fildor Nov 14 '22 at 19:38
  • The server sends an invalid response if using http. The only way to receive a valid response is by mean of https. – jstuardo Nov 14 '22 at 19:45
  • Oh wait ... I just read again. The protocol _is in fact_ http**s** but the server has no cert? Can you post the error message you are getting? – Fildor Nov 14 '22 at 19:45
  • 1
    "The remote certificate is invalid according to the validation procedure.". If one could make Tiny Restclient not to validate the certificate, it would be great. – jstuardo Nov 14 '22 at 19:47

1 Answers1

0

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);
Julien
  • 437
  • 4
  • 11