delvedor / hpagent

A ready to use http and https agent for working with proxies that keeps connections alive!
MIT License
182 stars 36 forks source link

Can't work with HTTPS proxy server. #43

Closed UchihaYuki closed 2 years ago

UchihaYuki commented 2 years ago

The following code work:

const { body } = await got("https://ipapi.co/json/", {
        agent: {
          https: new hpagent.HttpsProxyAgent({
            proxy: `http://user:pass@proxy.packetstream.io:port`
          })
        },
        headers: {
          "User-Agent":
            "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36",
        },
        responseType: "json",
        timeout: {
          request: 5e3,
        },
      });

But if I use an HTTPS server instead

https: new hpagent.HttpsProxyAgent({
       proxy: `https://user:pass@proxy.packetstream.io:port`
})

It will give me the following error

Hostname/IP does not match certificate's altnames: Host: ipapi.co. is not in the cert's altnames: DNS:*.packetstream.io, DNS:packetstream.io

It seems it mess up with the certificate of request and proxy server.

The same HTTPS proxy server work with https-proxy-agent (But that packet has some other problems)

soknifedev commented 2 years ago

did you find any solution?

freeqaz commented 2 years ago

I just posted up that PR which fixes this issue.

ckcr4lyf commented 2 years ago

Yep, also facing this issue. The TLS handshake to proxy contains hostname of actual target:

image

delvedor commented 2 years ago

Closed in https://github.com/delvedor/hpagent/pull/65.