Added the ability to fetch timestamp for codesigning through https (#6510)
Josiah Baldwin committed
Nov 10, 2024 at 06:39 UTC
01c585f7f19f83861fc5cc09ddbdf0c7b722c75e
1 file changed
+8
-4
authenticode.js
+8
-4
@@ -1566,7 +1566,11 @@ function createAuthenticodeHandler(path) {
1566
options.protocol = timeServerUrl.protocol;
1567
options.hostname = timeServerUrl.hostname;
1568
options.path = timeServerUrl.pathname;
1569
- options.port = ((timeServerUrl.port == '') ? 80 : parseInt(timeServerUrl.port));
1569
+ let http = require("http")
1570
+ if (options.protocol === "https:"){
1571
+ http = require("https")
1572
+ }
1573
+ options.port = ((timeServerUrl.port == '') ? (options.protocol === "https:" ? 443 : 80) : parseInt(timeServerUrl.port));
1574
1575
if (options.proxy == null) {
1576
// No proxy needed
@@ -1584,7 +1588,7 @@ function createAuthenticodeHandler(path) {
1588
1589
// Set up the request
1590
var responseAccumulator = '';
1587
- var req = require('http').request(options, function (res) {
1591
+ var req = http.request(options, function (res) {
1592
res.setEncoding('utf8');
1593
res.on('data', function (chunk) { responseAccumulator += chunk; });
1594
res.on('end', function () { func(null, responseAccumulator); });
@@ -1605,12 +1609,12 @@ function createAuthenticodeHandler(path) {
1609
proxyOptions.protocol = proxyUrl.protocol;
1610
proxyOptions.hostname = proxyUrl.hostname;
1611
proxyOptions.path = options.hostname + ':' + options.port;
1608
- proxyOptions.port = ((proxyUrl.port == '') ? 80 : parseInt(proxyUrl.port));
1612
+ proxyOptions.port = ((proxyUrl.port == '') ? (options.protocol === "https:" ? 443 : 80) : parseInt(proxyUrl.port));
1613
}
1614
1615
// Set up the proxy request
1616
var responseAccumulator = '';
1613
- var req = require('http').request(proxyOptions);
1617
+ var req = http.request(proxyOptions);
1618
req.on('error', function (err) { func('' + err); });
1619
req.on('connect', function (res, socket, head) {
1620
// Make a request over the HTTP tunnel