Skip to content

Commit

Permalink
propagate tls.connect options from the origin request to the proxy ag…
Browse files Browse the repository at this point in the history
…ent.
  • Loading branch information
Ballinette committed May 29, 2020
1 parent 4e8cf7b commit dc10582
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
28 changes: 28 additions & 0 deletions src/classes/Agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,34 @@ class Agent {
proxy,
};

// add optional tls options for https requests.
// @see https://nodejs.org/docs/latest-v12.x/api/https.html#https_https_request_url_options_callback :
// > The following additional options from tls.connect()
// > - https://nodejs.org/docs/latest-v12.x/api/tls.html#tls_tls_connect_options_callback -
// > are also accepted:
// > ca, cert, ciphers, clientCertEngine, crl, dhparam, ecdhCurve, honorCipherOrder,
// > key, passphrase, pfx, rejectUnauthorized, secureOptions, secureProtocol, servername, sessionIdContext.
if (this.protocol === 'https:') {
connectionConfiguration.tls = {
ca: configuration.ca,
cert: configuration.cert,
ciphers: configuration.ciphers,
clientCertEngine: configuration.clientCertEngine,
crl: configuration.crl,
dhparam: configuration.dhparam,
ecdhCurve: configuration.ecdhCurve,
honorCipherOrder: configuration.honorCipherOrder,
key: configuration.key,
passphrase: configuration.passphrase,
pfx: configuration.pfx,
rejectUnauthorized: configuration.rejectUnauthorized,
secureOptions: configuration.secureOptions,
secureProtocol: configuration.secureProtocol,
servername: configuration.servername || connectionConfiguration.host,
sessionIdContext: configuration.sessionIdContext,
};
}

// $FlowFixMe It appears that Flow is missing the method description.
this.createConnection(connectionConfiguration, (error, socket) => {
log.trace({
Expand Down
3 changes: 1 addition & 2 deletions src/classes/HttpsProxyAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ class HttpsProxyAgent extends Agent {

socket.once('data', () => {
const secureSocket = tls.connect({
rejectUnauthorized: false,
servername: configuration.host,
... configuration.tls,
socket,
});

Expand Down

0 comments on commit dc10582

Please sign in to comment.