@@ -8,7 +8,11 @@ import { Logger, getLogger } from '../../logger/logger'
8
8
import { ChildProcess } from '../../utilities/processUtils'
9
9
import { waitUntil } from '../../utilities/timeoutUtils'
10
10
import { isDebugInstance } from '../../vscode/env'
11
+ import { tmpdir } from 'os'
12
+ import { join } from 'path'
13
+ import * as fs from 'fs'
11
14
import * as vscode from 'vscode'
15
+ import * as tls from 'tls'
12
16
13
17
export function getNodeExecutableName ( ) : string {
14
18
return process . platform === 'win32' ? 'node.exe' : 'node'
@@ -106,33 +110,23 @@ export function getVSCodeSettings(): { proxyUrl?: string; certificatePath?: stri
106
110
}
107
111
108
112
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 } )
135
122
}
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 } ` )
136
130
}
137
131
} catch ( err ) {
138
132
logger . error ( `Failed to extract certificates: ${ err } ` )
0 commit comments