Repository navigation
Commit 068b90a
Connect to Azure SQL with certificate validation instead of disabling it (#122)
* Connect to SQL with the driver's certificate validation instead of disabling it
The connection string no longer carries TrustServerCertificate. Its default is already "no" in ODBC Driver 18, so the driver validates the server certificate, which is what Microsoft recommends: "Install a certificate on the server that the client trusts. This option is the recommended one, and it's the only one that keeps both encryption and validation" (https://learn.microsoft.com/sql/connect/odbc/major-version-differences#encryption-changes). Keeping the keyword at its default value only obscured that the sample was opting out of validation.
This works against LocalStack for Azure because the emulator now serves a publicly trusted certificate for the host name it returns in fullyQualifiedDomainName, so the sample no longer needs a local exception to run.
The same keyword is gone from the connection string that deploy.sh stores in Key Vault, since the app reads that value.
Verified end to end on both targets, with the sample otherwise unchanged:
- Real Azure: deploy.sh and validate.sh exit 0, and https://<app>.azurewebsites.net returns the app's own page with 9 cells rendered from the Azure SQL database.
- LocalStack for Azure: deploy.sh and validate.sh exit 0, and the app answers on the emulator endpoint with the same page and the same 9 cells.
If LocalStack cannot download its public certificate (for example with SKIP_SSL_CERT_DOWNLOAD=1) the server presents a certificate issued by the LocalStack root certificate authority, and a client then needs that authority installed or TrustServerCertificate=yes. The code comment says so.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Keep the stored connection string free of TrustServerCertificate too
deploy.sh writes the connection string into Key Vault and the app reads it from there, so leaving the keyword in that copy would keep suggesting that validation has to be disabled, even though the app no longer sets it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 06a6c35 commit 068b90a
2 files changed
Lines changed: 9 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
363 | | - | |
| 363 | + | |
364 | 364 | | |
365 | 365 | | |
366 | 366 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
170 | 169 | | |
171 | 170 | | |
172 | 171 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
178 | 180 | | |
179 | 181 | | |
180 | 182 | | |
| |||
0 commit comments