@@ -8,7 +8,11 @@ import { Logger, getLogger } from '../../logger/logger'
88import { ChildProcess } from '../../utilities/processUtils'
99import { waitUntil } from '../../utilities/timeoutUtils'
1010import { isDebugInstance } from '../../vscode/env'
11+ import { tmpdir } from 'os'
12+ import { join } from 'path'
13+ import * as fs from 'fs'
1114import * as vscode from 'vscode'
15+ import * as tls from 'tls'
1216
1317export function getNodeExecutableName ( ) : string {
1418 return process . platform === 'win32' ? 'node.exe' : 'node'
@@ -106,33 +110,23 @@ export function getVSCodeSettings(): { proxyUrl?: string; certificatePath?: stri
106110 }
107111
108112 try {
109- // @ts -ignore - This is a valid access pattern in VSCode extensions
110- const electron = require ( 'electron' )
111- if ( electron ?. net ?. getCACertificates ) {
112- const certs = electron . net . getCACertificates ( )
113- if ( certs && certs . length > 0 ) {
114- logger . info ( `Found ${ certs . length } certificates in VS Code's trust store` )
115-
116- // Create a temporary file with certificates
117- const fs = require ( 'fs' )
118- const os = require ( 'os' )
119- const path = require ( 'path' )
120-
121- const tempDir = path . join ( os . tmpdir ( ) , 'aws-toolkit-vscode' )
122- if ( ! fs . existsSync ( tempDir ) ) {
123- fs . mkdirSync ( tempDir , { recursive : true } )
124- }
125-
126- const certPath = path . join ( tempDir , 'vscode-ca-certs.pem' )
127- const certContent = certs
128- . filter ( ( cert : any ) => cert . pemEncoded )
129- . map ( ( cert : any ) => cert . pemEncoded )
130- . join ( '\n' )
131-
132- fs . writeFileSync ( certPath , certContent )
133- result . certificatePath = certPath
134- logger . info ( `Created certificate file at: ${ certPath } ` )
113+ // @ts -ignore - we need this function to access certs
114+ const certs = tls . getCACertificates ( )
115+ if ( certs && certs . length > 0 ) {
116+ logger . info ( `Found ${ certs . length } certificates in VS Code's trust store` )
117+
118+ // Create a temporary file with certificates
119+ const tempDir = join ( tmpdir ( ) , 'aws-toolkit-vscode' )
120+ if ( ! fs . existsSync ( tempDir ) ) {
121+ fs . mkdirSync ( tempDir , { recursive : true } )
135122 }
123+
124+ const certPath = join ( tempDir , 'vscode-ca-certs.pem' )
125+ const certContent = certs . join ( '\n' )
126+
127+ fs . writeFileSync ( certPath , certContent )
128+ result . certificatePath = certPath
129+ logger . info ( `Created certificate file at: ${ certPath } ` )
136130 }
137131 } catch ( err ) {
138132 logger . error ( `Failed to extract certificates: ${ err } ` )
0 commit comments