@@ -1566,7 +1566,11 @@ function createAuthenticodeHandler(path) {
1566
1566
options . protocol = timeServerUrl . protocol ;
1567
1567
options . hostname = timeServerUrl . hostname ;
1568
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 ) ) ;
1570
1574
1571
1575
if ( options . proxy == null ) {
1572
1576
// No proxy needed
@@ -1584,7 +1588,7 @@ function createAuthenticodeHandler(path) {
1584
1588
1585
1589
// Set up the request
1586
1590
var responseAccumulator = '' ;
1587
- var req = require ( ' http' ) . request ( options , function ( res ) {
1591
+ var req = http . request ( options , function ( res ) {
1588
1592
res . setEncoding ( 'utf8' ) ;
1589
1593
res . on ( 'data' , function ( chunk ) { responseAccumulator += chunk ; } ) ;
1590
1594
res . on ( 'end' , function ( ) { func ( null , responseAccumulator ) ; } ) ;
@@ -1605,12 +1609,12 @@ function createAuthenticodeHandler(path) {
1605
1609
proxyOptions . protocol = proxyUrl . protocol ;
1606
1610
proxyOptions . hostname = proxyUrl . hostname ;
1607
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 ) ) ;
1609
1613
}
1610
1614
1611
1615
// Set up the proxy request
1612
1616
var responseAccumulator = '' ;
1613
- var req = require ( ' http' ) . request ( proxyOptions ) ;
1617
+ var req = http . request ( proxyOptions ) ;
1614
1618
req . on ( 'error' , function ( err ) { func ( '' + err ) ; } ) ;
1615
1619
req . on ( 'connect' , function ( res , socket , head ) {
1616
1620
// Make a request over the HTTP tunnel
0 commit comments