Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/web-app-sql-database/python/scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ else
fi

# Build connection string
SQL_CONNECTION_STRING="Server=tcp:${SQL_SERVER_FQDN},1433;Database=${SQL_DATABASE_NAME};User ID=${DATABASE_USER_NAME};Password=${DATABASE_USER_PASSWORD};Encrypt=yes;TrustServerCertificate=yes;Connection Timeout=30;"
SQL_CONNECTION_STRING="Server=tcp:${SQL_SERVER_FQDN},1433;Database=${SQL_DATABASE_NAME};User ID=${DATABASE_USER_NAME};Password=${DATABASE_USER_PASSWORD};Encrypt=yes;Connection Timeout=30;"

# Create secret
echo "Creating secret [$SECRET_NAME] in Key Vault..."
Expand Down
14 changes: 8 additions & 6 deletions samples/web-app-sql-database/python/src/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,17 @@ def _build_connection_string(self) -> str:
f"Server=tcp:{self.server},1433;"
f"Database={self.database};"
f"Encrypt=yes;"
f"TrustServerCertificate=yes;"
f"Connection Timeout={self.connection_timeout};"
)

# TrustServerCertificate=yes tells the ODBC driver to accept self-signed certificates without verification
# This is appropriate for:
# - Local development with Docker containers
# - Testing environments with self-signed certificates
# - Internal networks where you control the SQL Server
# TrustServerCertificate is deliberately absent: its default is already "no" in ODBC Driver 18,
# so the driver validates the server certificate, which is what Microsoft recommends
# (https://learn.microsoft.com/sql/connect/odbc/major-version-differences#encryption-changes).
# That works against Azure SQL Database and against LocalStack for Azure alike, because the
# emulator serves a publicly trusted certificate for the host name it returns in
# fullyQualifiedDomainName. Add TrustServerCertificate=yes only if LocalStack could not
# download that certificate (for example with SKIP_SSL_CERT_DOWNLOAD=1), in which case the
# server presents a certificate issued by the LocalStack root certificate authority.

if not self.use_azure_credential:
# Traditional SQL authentication
Expand Down
Loading