@@ -12,7 +12,6 @@ import { tmpdir } from 'os'
1212import { join } from 'path'
1313import * as nodefs from 'fs' // eslint-disable-line no-restricted-imports
1414import * as vscode from 'vscode'
15- import * as tls from 'tls'
1615
1716export function getNodeExecutableName ( ) : string {
1817 return process . platform === 'win32' ? 'node.exe' : 'node'
@@ -89,18 +88,11 @@ export async function validateNodeExe(nodePath: string[], lsp: string, args: str
8988/**
9089 * Gets proxy settings and certificates from VS Code
9190 */
92- export function getVSCodeSettings ( ) : { proxyUrl ?: string ; certificatePath ?: string } {
91+ export async function getVSCodeSettings ( ) : Promise < { proxyUrl ?: string ; certificatePath ?: string } > {
9392 const result : { proxyUrl ?: string ; certificatePath ?: string } = { }
9493 const logger = getLogger ( 'amazonqLsp' )
9594
9695 try {
97- // Check if user already has NODE_EXTRA_CA_CERTS set
98- const userCerts = process . env . NODE_EXTRA_CA_CERTS
99- if ( userCerts ) {
100- logger . info ( `User already has NODE_EXTRA_CA_CERTS set: ${ userCerts } ` )
101- return result
102- }
103-
10496 // Get proxy settings from VS Code configuration
10597 const httpConfig = vscode . workspace . getConfiguration ( 'http' )
10698 const proxy = httpConfig . get < string > ( 'proxy' )
@@ -110,10 +102,18 @@ export function getVSCodeSettings(): { proxyUrl?: string; certificatePath?: stri
110102 }
111103
112104 try {
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` )
105+ const tls = await import ( 'node:tls' )
106+
107+ // @ts -ignore Get system certificates
108+ const systemCerts = tls . getCACertificates ( 'system' )
109+
110+ // @ts -ignore Get any existing extra certificates
111+ const extraCerts = tls . getCACertificates ( 'extra' )
112+
113+ // Combine all certificates
114+ const allCerts = [ ...systemCerts , ...extraCerts ]
115+ if ( allCerts && allCerts . length > 0 ) {
116+ logger . info ( `Found ${ allCerts . length } certificates in system's trust store` )
117117
118118 // Create a temporary file with certificates
119119 const tempDir = join ( tmpdir ( ) , 'aws-toolkit-vscode' )
@@ -122,7 +122,7 @@ export function getVSCodeSettings(): { proxyUrl?: string; certificatePath?: stri
122122 }
123123
124124 const certPath = join ( tempDir , 'vscode-ca-certs.pem' )
125- const certContent = certs . join ( '\n' )
125+ const certContent = allCerts . join ( '\n' )
126126
127127 nodefs . writeFileSync ( certPath , certContent )
128128 result . certificatePath = certPath
@@ -168,15 +168,12 @@ export function createServerOptions({
168168 }
169169
170170 // Get settings from VS Code
171- const settings = getVSCodeSettings ( )
171+ const settings = await getVSCodeSettings ( )
172172 const logger = getLogger ( 'amazonqLsp' )
173173
174174 // Add proxy settings to the Node.js process
175175 if ( settings . proxyUrl ) {
176176 processEnv . HTTPS_PROXY = settings . proxyUrl
177- processEnv . HTTP_PROXY = settings . proxyUrl
178- processEnv . https_proxy = settings . proxyUrl
179- processEnv . http_proxy = settings . proxyUrl
180177 }
181178
182179 // Add certificate path if available
0 commit comments