@@ -86,6 +86,7 @@ export class BatchExplorerApplication {
8686 this . _setupProcessEvents ( ) ;
8787 this . _registerFileProtocol ( ) ;
8888 await this . proxySettings . init ( ) ;
89+ this . _applyProxySettings ( ) ;
8990 this . storageBlobAdapter . init ( ) ;
9091 }
9192
@@ -365,4 +366,44 @@ export class BatchExplorerApplication {
365366 callback ( { cancel : false , requestHeaders : details . requestHeaders } ) ;
366367 } ) ;
367368 }
369+
370+ private async _trustedDomains ( ) : Promise < string [ ] > {
371+ return [
372+ "https://raw.githubusercontent.com" ,
373+ "https://batch.azure.com" , // Public data-plane API calls
374+ this . properties . azureEnvironment . aadUrl ,
375+ this . properties . azureEnvironment . arm ,
376+ this . properties . azureEnvironment . batch ,
377+ this . properties . azureEnvironment . msGraph ,
378+ this . properties . azureEnvironment . storageEndpoint
379+ ] . map ( url => {
380+ try {
381+ // Ensure the URL has a protocol (default to "https://")
382+ const normalized = url . startsWith ( "http" ) ? url : `https://${ url } ` ;
383+ return new URL ( normalized ) . hostname ;
384+ } catch ( error ) {
385+ console . error ( `Invalid URL: ${ url } ` , error ) ;
386+ return null ; // Handle invalid URLs gracefully
387+ }
388+ } ) . filter ( Boolean ) ;
389+ }
390+
391+ private async _applyProxySettings ( ) {
392+ const settings = await this . proxySettings . settings ;
393+
394+ const conf = settings . http || settings . https ;
395+ const proxyUrl = `${ conf . protocol } ://${ conf . host } :${ conf . port } ` ;
396+
397+ session . defaultSession . setProxy ( { proxyRules : proxyUrl } ) ;
398+
399+ const trustedDomains = await this . _trustedDomains ( ) ;
400+ session . defaultSession . setCertificateVerifyProc ( ( request , verifyCert ) => {
401+ if ( trustedDomains . some ( host => request . hostname . includes ( host ) ) ) {
402+ verifyCert ( 0 ) ; // trust the certificate
403+ } else {
404+ console . error ( "Untrusted certificate" , request . hostname ) ;
405+ verifyCert ( - 3 ) ;
406+ }
407+ } ) ;
408+ }
368409}
0 commit comments