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

connectOpts are ignored when upgrading socket connection to TLS #194

Open
joerg1985 opened this issue Jun 1, 2023 · 0 comments
Open

connectOpts are ignored when upgrading socket connection to TLS #194

joerg1985 opened this issue Jun 1, 2023 · 0 comments

Comments

@joerg1985
Copy link

joerg1985 commented Jun 1, 2023

I need to set a client certificate to connect to our service, when using a proxy the connection fails.
new HttpsProxyAgent(process.env.HTTPS_PROXY, { pfx: buffer })

These connectOpts options are only used to connect, but when the connection is upgraded the connectOpts are ignored.

return tls.connect({
...omit(opts, 'host', 'path', 'port'),
socket,
servername: net.isIP(servername) ? undefined : servername,
});

My perfered option would be to have second argument to the HttpsProxyAgent class with upgradeOpts.
new HttpsProxyAgent(process.env.HTTPS_PROXY, {}, { pfx: buffer })

When upgrading the connection these could be used with the regular options:

...omit(opts, 'host', 'path', 'port'),
...this.upgradeOpts,

With the new argument it would be even possible to connect to a https proxy with a client certificate and to the remote server with another client certificate. When using the original connectOpts setting a client certificate might disturb the connection to the proxy server.

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

1 participant