Skip to content

Commit 2b7abcc

Browse files
authored
Merge pull request #94 from Azure-Samples/copilot/fix-code-scanning-alerts
fix: remove rejectUnauthorized: false — resolve CodeQL certificate validation alert
2 parents 62c7add + 124168b commit 2b7abcc

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

‎api/src/shared/cosmosdb.ts‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,10 @@ export async function initializeStorage(): Promise<void> {
8787
clientOptions.agent = new https.Agent({ ca })
8888
console.log(`🔒 Using custom CA cert from ${emulatorCertPath}`)
8989
} else {
90-
// SAFETY: Only allow insecure connections in non-production environments
91-
if (process.env.ENVIRONMENT === 'prod') {
92-
throw new Error('Cannot disable TLS verification in production environment')
93-
}
94-
console.warn(`⚠️ Emulator CA cert not found. Using insecure Cosmos DB TLS agent (localhost only)`)
95-
clientOptions.agent = new https.Agent({ rejectUnauthorized: false }) // eslint-disable-line -- safe: only for local emulator, blocked in prod
90+
throw new Error(
91+
`Cosmos DB Emulator CA certificate not found at "${emulatorCertPath}". ` +
92+
`Run the emulator setup script or set COSMOS_EMULATOR_CERT_PATH to a valid cert file.`
93+
)
9694
}
9795
} catch (err) {
9896
console.warn(`⚠️ Error reading emulator CA certificate:`, err)

0 commit comments

Comments
 (0)