status-im / nim-chronos

Chronos - An efficient library for asynchronous programming
https://status-im.github.io/nim-chronos/docs/chronos
Apache License 2.0
353 stars 51 forks source link

httpclient can't connect to IP with HTTPS #386

Open hugosenari opened 1 year ago

hugosenari commented 1 year ago

I was following example of #345 Basically changed https://api.ipify.org by https://1.1.1.1 but it fails

httpcommon.nim:86        raiseHttpConnectionError
asyncfutures2.nim:509    internalCheckComplete
???                      acquireConnection
asyncfutures2.nim:509    internalCheckComplete
httpclient.nim:1127      send
???                      send
asyncfutures2.nim:509    internalCheckComplete
httpclient.nim:1425      fetch
???                      fetch
asyncfutures2.nim:509    internalCheckComplete
Error: unhandled exception: Could not connect to remote host [HttpConnectionError]

It works with http://1.1.1.1 (we got the 301/redirect) It works with https://one.one.one.one

I tried to be verbose and create address with fake hostname

HttpAddress(
      addresses: @[initTAddress("10.200.10.200", 9200)],
      id       : "10.200.10.200:9200",
      hostname : "babalu.aye",
      port     : 9200.uint16,
      path     : "/mys-elasticsearch-index/_search",
      query    : "",
      anchor   : "",
      username : "",
      password : "",
      scheme   : Secure,
    )

But got the same error, not sure if because the certificate (self signed) or same issue as 1.1.1.1

My real use case is connect to https in some internal server.