SQL Server Connection Strings
Section titled “ SQL Server Connection Strings”A comprehensive guide to configuring SQL Server connection strings for Nodinite components. This page covers modern TLS certificate validation, Always On Availability Groups, authentication methods, troubleshooting, and security best practices.
Overview
Section titled “ Overview”Nodinite Core Services connect to the Configuration Database with a connection string; the Configuration Database then reaches the Log Databases through Linked Servers, and some Monitoring Agents use their own Monitoring Database.
Where You Set the Connection String in v7
Section titled “Where You Set the Connection String in v7”For the Core Services, you set the connection string once per environment in the Nodinite Portal (Step 3: Infrastructure), or pass it to the CLI at install or update time with --database-connection-string (see Passing arguments when needed). The CLI writes it into each Core Service, and Nodinite protects it with Secret Management. To change it later, for example after a database migration, change it in the Portal and run the update again.
Choose the Encryption Settings
Section titled “Choose the Encryption Settings”TrustServerCertificate=False
SQL authentication"] Azure -->|"No"| CA{"SQL Server certificate from a CA
trusted by the Nodinite server?"} CA -->|"Yes"| Best["Encrypt=True
TrustServerCertificate=False"] CA -->|"No, self-signed"| Pragmatic["Encrypt=True
TrustServerCertificate=True"] Best --> AG{"Always On listener?"} Pragmatic --> AG AG -->|"Yes"| Multi["Add MultiSubnetFailover=True"] style AzureCfg fill:#2678BD style Best fill:#93d16d style Pragmatic fill:#FFD525 style Multi fill:#3F827B
Diagram: how to pick Encrypt and TrustServerCertificate. Green is the recommended production setting, yellow the pragmatic setting for self-signed certificates, and blue Azure SQL Managed Instance. Add MultiSubnetFailover=True for an Always On Availability Group listener. The Certificate Validation Decision Guide below rates every option.
Why the Defaults Changed
Section titled “Why the Defaults Changed”Nodinite components connect to SQL Server databases using connection strings. Starting with Microsoft.Data.SqlClient v4+, default security settings have changed, requiring explicit configuration for certificate validation and encryption.
What Changed
Section titled “What Changed”| Library Version | Default Behavior | Connection String Requirements |
|---|---|---|
| System.Data.SqlClient (legacy) | Encrypt=False (no TLS)TrustServerCertificate=True (accept any cert) |
✅ Encryption parameters optional ❌ Old connection strings often have no Encrypt/TrustServerCertificate parameters at all |
| Microsoft.Data.SqlClient v4+ (modern) | Encrypt=True (TLS required)TrustServerCertificate=False (validate cert chain) |
⚠️ Encryption parameters now mandatory ✅ Must explicitly add Encrypt=True;TrustServerCertificate=True/False |
Impact
Section titled “Impact”- Upgrading from System.Data.SqlClient: Old connection strings without
EncryptorTrustServerCertificateparameters will cause "The certificate chain was issued by an authority that is not trusted" errors - Upgrading Nodinite components: If SQL Server uses self-signed certificates, you must add encryption parameters to existing connection strings
Common Connection String Examples
Section titled “ Common Connection String Examples”Basic Connection (Self-Signed Certificate)
Section titled “Basic Connection (Self-Signed Certificate)”Data Source=localhost;Initial Catalog=DatabaseName;Integrated Security=True;Encrypt=True;TrustServerCertificate=True;Use when: Dev/test environments with self-signed certificates
Production Connection (Trusted CA)
Section titled “Production Connection (Trusted CA)”Data Source=SQL01\INSTANCE;Initial Catalog=DatabaseName;Integrated Security=True;Encrypt=True;TrustServerCertificate=False;Use when: Production with properly configured SQL Server certificates from trusted CA
SQL Authentication
Section titled “SQL Authentication”Data Source=sql.contoso.com,1433;Initial Catalog=DatabaseName;User ID=nodinite_user;Password=***;Encrypt=True;TrustServerCertificate=True;Use when: Windows Authentication not available (not recommended for production)
Connection String Settings
Section titled “ Connection String Settings”| Setting | Purpose | Values | Default (v4+) |
|---|---|---|---|
| Data Source | SQL Server instance name or IP | localhost, SQL01, SQL01\INSTANCE, 192.168.1.10,1433 |
Required |
| Initial Catalog | Database name | Database name | Required |
| Integrated Security | Windows authentication | True (recommended), False |
False |
| User ID / Password | SQL Server authentication | Username and password | (none) |
| Encrypt | TLS encryption on/off | True (recommended), False, Mandatory, Strict |
True |
| TrustServerCertificate | Skip certificate validation | True (self-signed), False (validate CA) |
False |
| MultiSubnetFailover | Always On AG fast failover | True (AG), False (standalone) |
False |
| ApplicationIntent | Read-only routing | ReadWrite (default), ReadOnly |
ReadWrite |
| Connect Timeout | Connection timeout (seconds) | 15, 30 (default), 60 |
30 |
| Pooling | Connection pooling | True (default), False |
True |
| Min Pool Size / Max Pool Size | Pool limits | 0 / 100 (defaults) |
0 / 100 |
See the complete connection string reference.
Certificate Validation Decision Guide
Section titled “ Certificate Validation Decision Guide”Choose the right certificate configuration for your environment:
| Scenario | Encrypt | TrustServerCertificate | Security Level | Use Case |
|---|---|---|---|---|
| Production with trusted CA | True |
False |
✅✅✅ Highest | SQL Server cert from public/enterprise CA, cert chain trusted by OS |
| Production with self-signed | True |
True |
✅✅ Medium | SQL Server uses self-signed cert, pragmatic security |
| Dev/Test | True |
True |
✅✅ Medium | Development environments, quick setup |
| Legacy (not recommended) | False |
N/A | ❌ Low | Old applications, testing only |
| Strict mode (SQL 2022+) | Strict |
False |
✅✅✅✅ Highest | Maximum security with TDS 8.0 |
Azure SQL Managed Instance
Section titled “ Azure SQL Managed Instance”Azure SQL Managed Instance is a fully managed SQL Server platform-as-a-service (PaaS) in Azure. It requires SQL authentication and always uses encrypted connections.
Basic Azure SQL Managed Instance Connection
Section titled “Basic Azure SQL Managed Instance Connection”Server=tcp:myinstance.database.windows.net,1433;Initial Catalog=DatabaseName;User ID=sqladmin;Password=***;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;Use when: Hosting Nodinite databases in Azure SQL Managed Instance
Recommended Azure SQL Managed Instance Settings
Section titled “Recommended Azure SQL Managed Instance Settings”| Setting | Value | Why |
|---|---|---|
| Server | tcp:yourinstance.database.windows.net,1433 |
Azure SQL Managed Instance FQDN |
| User ID / Password | SQL authentication credentials | Windows authentication not supported |
| Encrypt | True |
Required — Azure SQL enforces encryption |
| TrustServerCertificate | False |
Azure uses trusted CA certificates |
| Connection Timeout | 30 or higher |
Account for network latency to Azure |
| Persist Security Info | False (default) |
Security best practice |
| MultipleActiveResultSets | False (default) |
Use True if needed by application |
Full Example with Best Practices
Section titled “Full Example with Best Practices”Server=tcp:nodinite-prod.database.windows.net,1433;Initial Catalog=Nodinite_Prod_Config;Persist Security Info=False;User ID=nodinite_admin;Password=ComplexP@ssw0rd!;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;Azure SQL Database vs Managed Instance
Section titled “Azure SQL Database vs Managed Instance”| Feature | Azure SQL Database | Azure SQL Managed Instance |
|---|---|---|
| Nodinite Core Services support | ❌ Not supported | ✅ Supported (>=6.1) |
| Connection String | Similar format | tcp:instance.database.windows.net |
| Authentication | SQL auth only | SQL auth only |
| Encryption | Always encrypted | Always encrypted |
| Compatibility | Limited T-SQL | Near 100% SQL Server compatibility |
| Linked Servers | Not supported | ✅ Supported |
| SQL Agent | Not available | ✅ Available |
Azure SQL Managed Instance Checklist
Section titled “Azure SQL Managed Instance Checklist”- ✅ Use Azure SQL Managed Instance, not Azure SQL Database
- ✅ Create SQL login with appropriate permissions
- ✅ Set
Encrypt=True(enforced by Azure) - ✅ Keep
TrustServerCertificate=False(Azure uses trusted certificates) - ✅ Configure Azure firewall to allow Nodinite server's IP address
- ✅ Consider using private endpoint for secure connectivity
- ✅ Increase
Connection Timeout=60if experiencing network latency - ✅ Store passwords in secure secret management (Azure Key Vault, etc.)
Common Azure SQL Issues
Section titled “Common Azure SQL Issues”| Symptom | Cause | Solution |
|---|---|---|
| "Cannot open server" | Firewall blocking connection | Add client IP to Azure SQL firewall rules |
| "Login failed for user" | Invalid credentials | Verify username/password, check SQL login exists |
| Connection timeout | Network latency to Azure | Increase Connection Timeout=60 or higher |
| "Server was not found" | Incorrect server name | Verify FQDN format: tcp:instance.database.windows.net,1433 |
Always On Availability Groups (AOAG)
Section titled “ Always On Availability Groups (AOAG)”Why Use AOAG?
Section titled “Why Use AOAG?”Always On Availability Groups provide high availability and disaster recovery for SQL Server databases. When Nodinite connects to AOAG, the AG listener handles automatic failover—ensuring minimal downtime during SQL Server maintenance or failures.
Minimum AOAG Connection String
Section titled “Minimum AOAG Connection String”Data Source=AG-Listener;Initial Catalog=DatabaseName;Integrated Security=True;Encrypt=True;TrustServerCertificate=True;This works, but reconnection after failover may take 10-20 seconds.
Recommended AOAG Connection String
Section titled “Recommended AOAG Connection String”Data Source=AG-Listener;Initial Catalog=DatabaseName;Integrated Security=True;Encrypt=True;TrustServerCertificate=True;MultiSubnetFailover=True;Optimized for fast failover (2-3 seconds vs 10-20 seconds).
Key AOAG Settings
Section titled “Key AOAG Settings”| Setting | Required? | Purpose | Impact if Missing |
|---|---|---|---|
| Data Source (listener) | ✅ Required | Connect via AG listener, not individual nodes | Connection fails or points to wrong replica after failover |
| MultiSubnetFailover=True | ⚡ Recommended | Parallel connection attempts for faster failover | Slower reconnection (10-20s vs 2-3s) |
| ApplicationIntent | Optional | ReadWrite ensures writes go to primary |
Rare: may route to read-only secondary |
| Connect Timeout | Optional | Increase to 60s if slow failovers | Connection may timeout during failover |
When is MultiSubnetFailover=True Critical?
Section titled “When is MultiSubnetFailover=True Critical?”- Multi-subnet deployments (different datacenters/availability zones) — Critical for acceptable failover times
- Single-subnet deployments — Helpful but not required; reduces failover from ~15s to ~3s
- Production workloads — Recommended; improves perceived reliability during maintenance
AOAG Deployment Checklist
Section titled “AOAG Deployment Checklist”- ✅ Use the AG listener name as Data Source—never individual SQL Server names (Required)
- ✅ Verify database is in the AG and synchronized (Required)
- ⚡ Add
MultiSubnetFailover=Truefor faster failover (Recommended for multi-subnet) - ⚡ Test failover: stop primary replica, verify automatic reconnection
- ⚡ Increase
Connect Timeout=60if intermittent timeout errors during failover - ⚡ Configure AG listener with static IP addresses for predictable DNS resolution
Common AOAG Issues
Section titled “Common AOAG Issues”| Symptom | Cause | Solution |
|---|---|---|
| Slow reconnection (10-20 seconds) | Missing MultiSubnetFailover=True |
Add MultiSubnetFailover=True |
| "Login failed for user" after failover | SQL logins not synchronized | Use Windows auth OR sync logins to all replicas |
| Timeout errors during failover | Default timeout too short | Increase Connect Timeout=60 |
| Connects to read-only secondary | Incorrect routing configuration | Add ApplicationIntent=ReadWrite |
| Connection hangs (multi-subnet) | Sequential IP attempts with timeouts | Add MultiSubnetFailover=True (critical) |
Troubleshooting Certificate Errors
Section titled “ Troubleshooting Certificate Errors”"The certificate chain was issued by an authority that is not trusted"
Section titled “"The certificate chain was issued by an authority that is not trusted"”Cause: SQL Server uses a self-signed certificate or certificate from untrusted CA
Solutions
Section titled “Solutions”-
Best practice (Production):
- Export SQL Server certificate's root CA certificate
- Install on Nodinite host's Trusted Root Certification Authorities store
- Keep
Encrypt=True;TrustServerCertificate=Falsein connection string
-
Pragmatic (Dev/Test):
- Add
TrustServerCertificate=Trueto connection string - Keeps encryption but bypasses certificate validation
- Add
-
Not recommended:
- Set
Encrypt=Falsein connection string - Disables TLS encryption entirely
- Set
"The target principal name is incorrect"
Section titled “"The target principal name is incorrect"”Cause: Certificate CN/SAN doesn't match the Data Source name
Solutions
Section titled “Solutions”- Use DNS name from certificate in
Data Sourcesetting - OR update SQL Server certificate with correct SAN entries
- OR add
TrustServerCertificate=True(bypasses name check)
TLS Handshake Failures
Section titled “TLS Handshake Failures”Cause: TLS protocol version mismatch
Solutions
Section titled “Solutions”- Enable TLS 1.2+ in Windows (via registry)
- Enable TLS 1.2+ in SQL Server configuration
- Update .NET Framework to support modern TLS
Connection Timeout During Failover (AOAG)
Section titled “Connection Timeout During Failover (AOAG)”Cause: Default 30-second timeout too short for AG failover
Solution
Section titled “Solution”- Add
Connect Timeout=60to connection string - Verify
MultiSubnetFailover=Trueis present
Password with Special Characters
Section titled “Password with Special Characters”Cause: Passwords containing special characters like ; (semicolon) are misinterpreted as connection string delimiters
Solutions
Section titled “Solutions”-
Best practice (All environments):
- Use Windows Authentication (
Integrated Security=True) to avoid passwords in connection strings entirely - See Secret Management for secure credential storage
- Use Windows Authentication (
-
If SQL Authentication required:
- Escape the password by enclosing it in single quotes:
Data Source=localhost;Initial Catalog=MSDB;User ID=ServiceAccountName;Password='Da;Password';- Characters that require escaping:
;='(any delimiter used in connection strings)
-
Not recommended:
- Avoid passwords with special characters (limits password complexity)
Example
Section titled “Example”❌ Incorrect (password interpreted as multiple parameters):
Server=localhost;Database=MSDB;User Id=ServiceAccountName;Password=Da;Password;✅ Correct (password enclosed in single quotes):
Server=localhost;Database=MSDB;User Id=ServiceAccountName;Password='Da;Password';Security Best Practices
Section titled “ Security Best Practices”Do This
Section titled “ Do This”- Use
Encrypt=Trueeverywhere — Encrypts all data in transit - Prefer
TrustServerCertificate=Falsewith proper CA trust — Validates certificate chain - Use Windows Authentication (
Integrated Security=True) — No passwords in connection strings - For AOAG, use listener name and
MultiSubnetFailover=True— Ensures fast failover - Use least-privilege SQL accounts — Grant only necessary permissions
- Rotate SQL passwords regularly — If SQL auth is required
- Enable SSL/TLS 1.2+ — Disable older protocols
Avoid This
Section titled “ Avoid This”Encrypt=Falsein production — Sends data unencrypted over network- Embedding passwords in connection strings — Use Windows auth or secure secret storage
- SQL Authentication without encryption — Passwords sent in cleartext if
Encrypt=False - Self-signed certificates in production without documentation — Creates security debt
- Individual SQL Server names with AOAG — Breaks automatic failover
Connection String Security Levels
Section titled “Connection String Security Levels”| Configuration | Security Rating | Production Ready? |
|---|---|---|
Encrypt=True;TrustServerCertificate=False + trusted CA |
✅✅✅✅ Excellent | ✅ Yes |
Encrypt=True;TrustServerCertificate=True + Windows auth |
✅✅✅ Good | ✅ Yes (pragmatic) |
Encrypt=True;TrustServerCertificate=True + SQL auth |
✅✅ Fair | ⚠️ Use with caution |
Encrypt=False + Windows auth |
✅ Poor | ❌ Dev/test only |
Encrypt=False + SQL auth |
❌ Very Poor | ❌ Never use |
External References
Section titled “ External References”- Microsoft.Data.SqlClient documentation
- Connection string syntax
- SQL Server Always On Availability Groups
- MultiSubnetFailover keyword
- SQL Server TLS/SSL configuration
Next Steps
Section titled “ Next Steps”- SQL Server Firewall Configuration
- Always On Availability Groups
- Secret Management
- Step 3: Infrastructure