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

fix(devtools-proxy-support): remove ability to specify per-request CA #449

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions packages/devtools-proxy-support/src/agent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ describe('createAgent', function () {
new URL(url).protocol === 'https:' ? httpsGet : httpGet;
const options = {
agent,
ca: setup.tlsOptions.ca,
checkServerIdentity: () => undefined, // allow hostname mismatches
...customOptions,
};
Expand Down Expand Up @@ -142,7 +141,10 @@ describe('createAgent', function () {
it('can connect to an https proxy without auth', async function () {
const res = await get(
'https://example.com/hello',
createAgent({ proxy: `http://127.0.0.1:${setup.httpsProxyPort}` })
createAgent({
proxy: `http://127.0.0.1:${setup.httpsProxyPort}`,
ca: setup.tlsOptions.ca,
})
);
expect(res.body).to.equal('OK /hello');
expect(setup.getRequestedUrls()).to.deep.equal([
Expand All @@ -157,6 +159,7 @@ describe('createAgent', function () {
'https://example.com/hello',
createAgent({
proxy: `http://foo:[email protected]:${setup.httpsProxyPort}`,
ca: setup.tlsOptions.ca,
})
);
expect(res.body).to.equal('OK /hello');
Expand All @@ -173,6 +176,7 @@ describe('createAgent', function () {
'https://example.com/hello',
createAgent({
proxy: `http://foo:[email protected]:${setup.httpsProxyPort}`,
ca: setup.tlsOptions.ca,
})
);
expect(res.statusCode).to.equal(407);
Expand All @@ -186,17 +190,6 @@ describe('createAgent', function () {
resetSystemCACache();
});

it('can connect using CA as part of the request options', async function () {
// get() helpfully sets the CA for us
const res = await get(
'https://example.com/hello',
createAgent({ proxy: `http://127.0.0.1:${setup.httpsProxyPort}` })
);
expect(res.body).to.equal('OK /hello');
expect(setup.getRequestedUrls()).to.deep.equal([
'http://example.com/hello',
]);
});
it('can connect using CA as part of the agent options (no explicit CA set)', async function () {
const res = await get(
'https://example.com/hello',
Expand Down
11 changes: 6 additions & 5 deletions packages/devtools-proxy-support/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ class DevtoolsProxyAgent extends ProxyAgent implements AgentWithInitialize {
private _reqLockResolve: (() => void) | undefined;

constructor(proxyOptions: DevtoolsProxyOptions, logger: ProxyLogEmitter) {
// We remove .ca because the Node.js HTTP agent implementation overrides
// request options with agent options, but we want to merge them instead
// NB: The Node.js HTTP agent implementation overrides request options
// with agent options. Ideally, we'd want to merge them, but it seems like
// there is little we can do about it at this point.
// None of our products need the ability to specify per-request CA options
// currently anyway.
// https://github.com/nodejs/node/blob/014dad5953a632f44e668f9527f546c6e1bb8b86/lib/_http_agent.js#L239
const { ca, ...proxyOptionsWithoutCA } = proxyOptions;
void ca;
super({
...proxyOptionsWithoutCA,
...proxyOptions,
getProxyForUrl: (url: string) => this._getProxyForUrl(url),
});

Expand Down
Loading