From d69b38846aec5431381770bc72b2da08186e89f3 Mon Sep 17 00:00:00 2001 From: Mark Wolff Date: Wed, 27 May 2020 14:36:20 -0400 Subject: [PATCH] Update all Senders to use https.globalAgent instead of tlsRestrictedAgent (#621) --- Library/QuickPulseSender.ts | 8 ++++++++ Library/Sender.ts | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Library/QuickPulseSender.ts b/Library/QuickPulseSender.ts index 5b4694fb..d3217014 100644 --- a/Library/QuickPulseSender.ts +++ b/Library/QuickPulseSender.ts @@ -2,6 +2,7 @@ import https = require("https"); import Config = require("./Config"); import AutoCollectHttpDependencies = require("../AutoCollection/HttpDependencies"); import Logging = require("./Logging"); +import Util = require("./Util"); // Types import * as http from "http"; @@ -50,6 +51,13 @@ class QuickPulseSender { } }; + // HTTPS only + if (this._config.httpsAgent) { + (options).agent = this._config.httpsAgent; + } else { + (options).agent = Util.tlsRestrictedAgent; + } + const req = https.request(options, (res: http.IncomingMessage) => { const shouldPOSTData = res.headers[QuickPulseConfig.subscribed] === "true"; this._consecutiveErrors = 0; diff --git a/Library/Sender.ts b/Library/Sender.ts index a8ca6068..fafce06d 100644 --- a/Library/Sender.ts +++ b/Library/Sender.ts @@ -223,7 +223,7 @@ class Sender { if (Sender.ACL_IDENTITY) { return callback(null, Sender.ACL_IDENTITY); } - var psProc = child_process.spawn(Sender.POWERSHELL_PATH, + var psProc = child_process.spawn(Sender.POWERSHELL_PATH, ["-Command", "[System.Security.Principal.WindowsIdentity]::GetCurrent().Name"], { windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] // Needed to prevent hanging on Win 7 @@ -245,7 +245,7 @@ class Sender { } // Some very old versions of Node (< 0.11) don't have this if (child_process.spawnSync) { - var psProc = child_process.spawnSync(Sender.POWERSHELL_PATH, + var psProc = child_process.spawnSync(Sender.POWERSHELL_PATH, ["-Command", "[System.Security.Principal.WindowsIdentity]::GetCurrent().Name"], { windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] // Needed to prevent hanging on Win 7