@@ -12,7 +12,6 @@ import { tmpdir } from 'os'
12
12
import { join } from 'path'
13
13
import * as nodefs from 'fs' // eslint-disable-line no-restricted-imports
14
14
import * as vscode from 'vscode'
15
- import * as tls from 'tls'
16
15
17
16
export function getNodeExecutableName ( ) : string {
18
17
return process . platform === 'win32' ? 'node.exe' : 'node'
@@ -89,18 +88,11 @@ export async function validateNodeExe(nodePath: string[], lsp: string, args: str
89
88
/**
90
89
* Gets proxy settings and certificates from VS Code
91
90
*/
92
- export function getVSCodeSettings ( ) : { proxyUrl ?: string ; certificatePath ?: string } {
91
+ export async function getVSCodeSettings ( ) : Promise < { proxyUrl ?: string ; certificatePath ?: string } > {
93
92
const result : { proxyUrl ?: string ; certificatePath ?: string } = { }
94
93
const logger = getLogger ( 'amazonqLsp' )
95
94
96
95
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
-
104
96
// Get proxy settings from VS Code configuration
105
97
const httpConfig = vscode . workspace . getConfiguration ( 'http' )
106
98
const proxy = httpConfig . get < string > ( 'proxy' )
@@ -110,10 +102,18 @@ export function getVSCodeSettings(): { proxyUrl?: string; certificatePath?: stri
110
102
}
111
103
112
104
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` )
117
117
118
118
// Create a temporary file with certificates
119
119
const tempDir = join ( tmpdir ( ) , 'aws-toolkit-vscode' )
@@ -122,7 +122,7 @@ export function getVSCodeSettings(): { proxyUrl?: string; certificatePath?: stri
122
122
}
123
123
124
124
const certPath = join ( tempDir , 'vscode-ca-certs.pem' )
125
- const certContent = certs . join ( '\n' )
125
+ const certContent = allCerts . join ( '\n' )
126
126
127
127
nodefs . writeFileSync ( certPath , certContent )
128
128
result . certificatePath = certPath
@@ -168,15 +168,12 @@ export function createServerOptions({
168
168
}
169
169
170
170
// Get settings from VS Code
171
- const settings = getVSCodeSettings ( )
171
+ const settings = await getVSCodeSettings ( )
172
172
const logger = getLogger ( 'amazonqLsp' )
173
173
174
174
// Add proxy settings to the Node.js process
175
175
if ( settings . proxyUrl ) {
176
176
processEnv . HTTPS_PROXY = settings . proxyUrl
177
- processEnv . HTTP_PROXY = settings . proxyUrl
178
- processEnv . https_proxy = settings . proxyUrl
179
- processEnv . http_proxy = settings . proxyUrl
180
177
}
181
178
182
179
// Add certificate path if available
0 commit comments