From 01c585f7f19f83861fc5cc09ddbdf0c7b722c75e Mon Sep 17 00:00:00 2001 From: Josiah Baldwin Date: Sun, 10 Nov 2024 06:39:12 -0800 Subject: [PATCH] Added the ability to fetch timestamp for codesigning through https (#6510) --- authenticode.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/authenticode.js b/authenticode.js index a3ff1a01..5f0bd441 100644 --- a/authenticode.js +++ b/authenticode.js @@ -1566,7 +1566,11 @@ function createAuthenticodeHandler(path) { options.protocol = timeServerUrl.protocol; options.hostname = timeServerUrl.hostname; options.path = timeServerUrl.pathname; - options.port = ((timeServerUrl.port == '') ? 80 : parseInt(timeServerUrl.port)); + let http = require("http") + if (options.protocol === "https:"){ + http = require("https") + } + options.port = ((timeServerUrl.port == '') ? (options.protocol === "https:" ? 443 : 80) : parseInt(timeServerUrl.port)); if (options.proxy == null) { // No proxy needed @@ -1584,7 +1588,7 @@ function createAuthenticodeHandler(path) { // Set up the request var responseAccumulator = ''; - var req = require('http').request(options, function (res) { + var req = http.request(options, function (res) { res.setEncoding('utf8'); res.on('data', function (chunk) { responseAccumulator += chunk; }); res.on('end', function () { func(null, responseAccumulator); }); @@ -1605,12 +1609,12 @@ function createAuthenticodeHandler(path) { proxyOptions.protocol = proxyUrl.protocol; proxyOptions.hostname = proxyUrl.hostname; proxyOptions.path = options.hostname + ':' + options.port; - proxyOptions.port = ((proxyUrl.port == '') ? 80 : parseInt(proxyUrl.port)); + proxyOptions.port = ((proxyUrl.port == '') ? (options.protocol === "https:" ? 443 : 80) : parseInt(proxyUrl.port)); } // Set up the proxy request var responseAccumulator = ''; - var req = require('http').request(proxyOptions); + var req = http.request(proxyOptions); req.on('error', function (err) { func('' + err); }); req.on('connect', function (res, socket, head) { // Make a request over the HTTP tunnel