Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rejectUnauthorized without proxy URL #248

Open
eamodio opened this issue Sep 12, 2023 · 4 comments
Open

Use rejectUnauthorized without proxy URL #248

eamodio opened this issue Sep 12, 2023 · 4 comments

Comments

@eamodio
Copy link

eamodio commented Sep 12, 2023

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?

@KyloJorgensen
Copy link

KyloJorgensen commented Sep 16, 2023

Same +1

I am having the issue with a url too

@JasserRomero
Copy link

any solution?

@eamodio
Copy link
Author

eamodio commented Jan 16, 2024

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

@raphendyr
Copy link

raphendyr commented Jul 16, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants