TooTallNate / proxy-agents

Node.js HTTP Proxy Agents Monorepo
https://proxy-agents.n8.io
919 stars 239 forks source link

ciphers option ignored #94

Closed gajus closed 1 year ago

gajus commented 4 years ago
// @flow

import url from 'url';
import crypto from 'crypto';
import got from 'got';
import Agent from 'https-proxy-agent';

(async () => {
  const response = (await got('https://www.howsmyssl.com/a/check', {
    agent: new Agent({
      ...url.parse('http://[..]'),
      ciphers: crypto.constants.defaultCipherList + ':!ECDHE+SHA:!AES128-SHA',
    }),
    responseType: 'json',
  })).body;

  console.log(response.given_cipher_suites.length);
})();

Changing ciphers configuration has no effect.

gajus commented 4 years ago

Looking at the source code, there appears to be no way to pass custom options to the upgrade phase connection.

https://github.com/TooTallNate/node-https-proxy-agent/blob/176d4b4fb20e229cf6cd1008f06bf97833fd725f/index.js#L151

kadler15 commented 4 years ago

This behavior changed over time because of agent-base being reworked. Try running your snipped with https-proxy-agent@2.2.4. You'll see that the ciphers option is passed on to the tls.connect call that upgrades the socket.

This issue is related to #92. Officially agent-base only supports a timeout option, but in reality agent-base@5 applies all of its constructor options to new requests. Because inheritance of the base agent is currently broken (again, see #92), your cipher option is not being passed to tls.connect. It looks like @TooTallNate made recent changes to agent-base, and once updated to v6+, agent-base will no longer apply its constructor options to requests.

You should pass the ciphers option directly to got. You can still provide ciphers as an https-proxy-agent option if you want it to be used when connecting to an HTTPS proxy server.

import url from 'url';
import crypto from 'crypto';
import got from 'got';
import Agent from 'https-proxy-agent';

(async () => {
  const response = (await got('https://www.howsmyssl.com/a/check', {
    agent: new Agent({
      ...url.parse('http://[..]'),
    }),
    ciphers: crypto.constants.defaultCipherList + ':!ECDHE+SHA:!AES128-SHA',
    responseType: 'json',
  })).body;

  console.log(response.given_cipher_suites.length);
})();
TooTallNate commented 1 year ago

This module has gone through a large refactor and modernization. I am closing this issue as a bit of house cleaning. If you feel that this issue still exists in the latest release, feel free to open a new issue.

rrajanaditya commented 5 months ago

still an issue