The most common error
SSL Provider: The certificate chain was issued by an authority that is not trusted.
It appears as soon as a new driver (ODBC Driver 18, Microsoft.Data.SqlClient 4.0 and later, current SSMS) with encryption on by default meets a server that only has its self-generated certificate. The quick workaround TrustServerCertificate=True turns verification off and makes the connection vulnerable. The proper fix is a certificate the clients trust.
Certificate requirements
- Enhanced key usage Server Authentication.
- The server’s fully qualified name in the SAN; for availability groups also the listener name, for clusters the name of the virtual instance.
- The key must be created with KeySpec AT_KEYEXCHANGE, i.e. stored in a legacy cryptographic service provider (CSP). If the certificate is missing from the list in Configuration Manager, this is almost always the reason. Check with
certutil -v -store myand look forKeySpec = 1. - Stored in Local Computer → Personal.
With certreq you get there with these lines in the INF file:
[NewRequest]
Subject = "CN=sql01.corp.local"
KeyLength = 2048
KeySpec = 1
MachineKeySet = TRUE
Exportable = TRUE
ProviderName = "Microsoft RSA SChannel Cryptographic Provider"
ProviderType = 12
RequestType = PKCS10
[EnhancedKeyUsageExtension]
OID = 1.3.6.1.5.5.7.3.1
[Extensions]
2.5.29.17 = "{text}"
_continue_ = "dns=sql01.corp.local&"
_continue_ = "dns=sql01"
Permissions for the service account
The SQL Server service account (e.g. NT Service\MSSQLSERVER) needs read access to the private key: certlm.msc → certificate → All Tasks → Manage Private Keys. Without it the service does not start after the assignment, and the error log says the certificate could not be loaded.
Assign the certificate and force encryption
- SQL Server Configuration Manager → SQL Server Network Configuration → Protocols for MSSQLSERVER → Properties.
- Certificate tab: select the certificate. From SQL Server 2019 Configuration Manager can also import certificates itself.
- Flags tab: set Force Encryption to Yes. SQL Server 2022 additionally has Force Strict Encryption (TDS 8.0, TLS before any other communication), which requires current drivers.
- Restart the service.
Check
SELECT session_id, encrypt_option, auth_scheme, client_net_address FROM sys.dm_exec_connections;
encrypt_option = TRUE means encrypted. On the client side a clean connection looks like this:
Server=sql01.corp.local;Database=App;Encrypt=True;TrustServerCertificate=False;Integrated Security=True
The server name in the connection string must match a name in the certificate. With the IP address verification fails, even if the CA is trusted.
More notes
- Configuration Manager rejects expired certificates. An already assigned certificate that expires keeps the service running, though. Watch the expiry date anyway.
- Java applications with the JDBC driver need the CA in their trust store, see import a CA into Java cacerts.
- The certificate converter builds a PFX from PEM files. On import Windows usually stores the key in the newer provider (KSP), though. For SQL Server a certreq request with
KeySpec = 1is the more reliable route.
FAQ
Is TrustServerCertificate=True bad?
The connection is encrypted but not verified. Anyone in the network path can pose as the server. Fine for tests, not for production.
Does every client need the CA?
Yes, if the certificate comes from an internal CA. In a domain you distribute the root CA by group policy, then nothing else is needed.
Why doesn’t my certificate appear in the list?
Usually because of KeySpec, missing Server Authentication, or because the server name is not in the certificate. For failover clusters Configuration Manager never shows a list; there you enter the thumbprint in the registry.