MCPcopy Create free account
hub / github.com/Noumena-Network/code / getExtraCertsPathFromConfig

Function getExtraCertsPathFromConfig

src/utils/caCertsConfig.ts:60–90  ·  view source on GitHub ↗

* Read NODE_EXTRA_CA_CERTS from settings/config as a fallback. * * NODE_EXTRA_CA_CERTS is categorized as a non-safe env var (it allows * trusting attacker-controlled servers), so it's only applied to process.env * after the trust dialog. But we need the CA cert early to establish the TLS * conn

()

Source from the content-addressed store, hash-verified

58 * files that don't require trust approval.
59 */
60function getExtraCertsPathFromConfig(): string | undefined {
61 try {
62 const globalConfig = getGlobalConfig()
63 const globalEnv = globalConfig?.env
64 // Only read from user-controlled user settings (typically
65 // ~/.ncode/settings.json; legacy ~/.claude/settings.json), not
66 // project-level settings, to prevent malicious projects from
67 // injecting CA certs before the trust dialog.
68 const settings = getSettingsForSource('userSettings')
69 const settingsEnv = settings?.env
70
71 logForDebugging(
72 `CA certs: Config fallback - globalEnv keys: ${globalEnv ? Object.keys(globalEnv).join(',') : 'none'}, settingsEnv keys: ${settingsEnv ? Object.keys(settingsEnv).join(',') : 'none'}`,
73 )
74
75 // Settings override global config (same precedence as applyConfigEnvironmentVariables)
76 const path =
77 settingsEnv?.NODE_EXTRA_CA_CERTS || globalEnv?.NODE_EXTRA_CA_CERTS
78 if (path) {
79 logForDebugging(
80 `CA certs: Found NODE_EXTRA_CA_CERTS in config/settings: ${path}`,
81 )
82 }
83 return path
84 } catch (error) {
85 logForDebugging(`CA certs: Config fallback failed: ${error}`, {
86 level: 'error',
87 })
88 return undefined
89 }
90}

Callers 1

Calls 4

getSettingsForSourceFunction · 0.85
keysMethod · 0.80
getGlobalConfigFunction · 0.70
logForDebuggingFunction · 0.70

Tested by

no test coverage detected