proxy-agents icon indicating copy to clipboard operation
proxy-agents copied to clipboard

Use `rejectUnauthorized` without proxy URL

Open eamodio opened this issue 2 years ago • 4 comments

In v5 I am creating a proxy agent for some use-cases where I only needed to set the rejectUnauthorized flag:

new HttpsProxyAgent({ rejectUnauthorized: false })

But in v7, I don't see how to do the same, since the following throws.

new HttpsProxyAgent('', { rejectUnauthorized: false })

How can this be accomplished in v7?

eamodio avatar Sep 12 '23 03:09 eamodio

Same +1

I am having the issue with a url too

KyloJorgensen avatar Sep 16 '23 19:09 KyloJorgensen

any solution?

JasserRomero avatar Nov 15 '23 14:11 JasserRomero

Anyone have any idea on this one? Would love to be able to move off of v5 if possible.

eamodio avatar Jan 16 '24 06:01 eamodio

Stumbled on your issue and it baffled me. Looking at the code, your v5 example should work, as it should hot the socket.connect, which defines that port is a required option. V5 had very naive test to ensure the host and port are defined https://github.com/TooTallNate/proxy-agents/blob/5.0.1/src/agent.ts#L38-L42, which of course doesn't trigger for your example.

Anyhow, assuming you are using proxy from your local host, then maybe something like new HttpsProxyAgent('http://localhost', { rejectUnauthorized: false }) would do the trick. Of course, this has little effect as the the tunnel is within your own machine.

If the proxy information is supposed to come from the environment, then I guess you would need https://www.npmjs.com/package/proxy-from-env , which is used by the proxy-agent in this repo: https://github.com/TooTallNate/proxy-agents/blob/main/packages/proxy-agent/src/index.ts#L100.

Additionally, the rejectUnauthorized only applies to the proxy connection (HTTP in above) and not for the actual TLS connection to the server. See #235 for solution to pass options to the actual server connection.

I hope this helps you to move forward.

raphendyr avatar Jul 16 '24 12:07 raphendyr