About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
If an application started failing right after its SQL driver was upgraded, with "[Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: The certificate chain was issued by an authority that is not trusted.", the new driver is doing something the old one did not do. Microsoft documents that form for ODBC Driver 18 and a matching one for OLE DB Driver 19 after an upgrade from SQL Server Native Client 11.0, where the Force encryption setting on the instance is No and the connection string sets no encryption value. For Microsoft.Data.SqlClient, Microsoft states that from 4.0 the default for Encrypt changed from false to true and that connections now validate the server certificate. A server that never had a proper certificate now shows it.
The Microsoft pages for Microsoft.Data.SqlClient describe the failure as a "certificate chain or name error" and do not print the exact message that SqlClient shows, so match on the cause. The causes and the fix below apply to each of these drivers.
The right fix is on the server: install a certificate the client trusts, with a name the client uses. Setting TrustServerCertificate=true makes the error go away by switching off the check that identifies the server.
What the error means
Microsoft's release notes say that "Starting with version 4.0, connections encrypt by default and validate the server certificate. Before 4.0, Encrypt defaulted to false." After the upgrade, "a server that presents a self-signed certificate, or a certificate whose name doesn't match the server name in the connection string, fails the connection with a certificate chain or name error."
Microsoft's SQL Server Native Client upgrade page also lists Encrypt=Optional as a temporary option for ODBC Driver 18 and OLE DB Driver 19; for Microsoft.Data.SqlClient the pages say Optional is not a remedy for certificate errors (see Fix). The wording that the client prints varies by driver and platform, so match on the cause rather than a string. Microsoft's troubleshooting table lists the failures as "Certificate chain isn't trusted.", "Certificate name doesn't match." and "Certificate is expired."
A related history is useful. In 2.0, server-forced encryption began to honour TrustServerCertificate even with Encrypt=false. Version 5.0 added the values Optional, Mandatory and Strict and the HostNameInCertificate keyword. Version 5.1 added ServerCertificate for pinning. The default in current releases is Encrypt=Mandatory with TrustServerCertificate=false.
SQL Server itself is not at fault here. When no usable certificate is installed, SQL Server generates a self-signed certificate at startup and logs "A self-generated certificate was successfully loaded for encryption." Microsoft says this certificate "doesn't protect against identity spoofing by the server", which is exactly what a validating client refuses to accept.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| Server is using its self-generated certificate | Chain not trusted; the error log has the self-generated line | Search the SQL error log for "A self-generated certificate was successfully loaded for encryption." |
| Certificate issued by a private CA the client does not trust | Chain not trusted on some clients only | Client lacks the issuing and intermediate certificates |
| Name in the connection string is not in the certificate | Name does not match | Compare the Server value with the certificate's Subject Alternative Name |
| Client connects through an alias or listener name | Name mismatch although the host is right | Connection string uses a DNS alias or availability group listener not in the SAN |
| Certificate expired | Certificate expired | Valid to date earlier than the client's clock |
| A certificate exists but SQL Server cannot use it | Server loads the self-generated one anyway | Wrong KeySpec, missing Server Authentication usage or no private-key permission |
| Linux container or separate machine | Works on the domain server, fails in the container | Enterprise root is not in the container's trust store |
Prove the cause before changing anything
Read-only checks, in this order.
- What certificate is the instance using? Search the SQL Server error log for the self-generated line above. If present, no valid certificate was loaded.
- Is the connection encrypted, and by what? On the server, Microsoft gives this query:
SELECT DISTINCT (encrypt_option) FROM sys.dm_exec_connections WHERE net_transport <> 'Shared memory';. A value of TRUE means the connection is encrypted; it does not say whether the certificate is trusted. - List certificates in the computer store and their KeySpec. Microsoft's PowerShell reads
Cert:\LocalMachine\Myand shows Subject, Thumbprint, KeySpec and NotAfter. KeySpec must read Exchange. For one certificate,certutil -v -store My "<certificate_thumbprint>"showsKeySpec = 1 -- AT_KEYEXCHANGE, Key Usage and the Enhanced Key Usage line for Server Authentication (1.3.6.1.5.5.7.3.1). Microsoft states thatKeySpec = 2can't be used, and that certificates from a Key Storage Provider useKeySpec = 0and aren't compatible. - Which name does the client use? Read the
Server=value in the failing connection string and compare it with the SAN. Microsoft's requirement is that the SAN include all the names clients might use to connect. - Does the client trust the issuer? On the client, open the certificate chain for the presented certificate. Microsoft says if the client has the issuing CA's public certificate, no more configuration is needed; otherwise install it on each client.
The sqlcheck tool, which Microsoft names on its certificate page, prints certificate details in one report for the instance.
Fix
Server using the self-generated certificate, or an unusable certificate. Provision a certificate that meets Microsoft's list: in the local computer store (or the service account store), readable by the SQL Server service account, valid now, with Server Authentication usage, created with AT_KEYEXCHANGE, and with the connecting names in the SAN. In SQL Server 2019 and later, SQL Server Configuration Manager manages certificates and validates the requirements. In earlier versions Microsoft describes importing into the computer store, granting the service account read permission on the private key, then choosing the certificate on the Certificate tab.
Disruptive step: selecting a certificate and restarting the SQL Server service drops every connection. Microsoft warns that a certificate that meets only some requirements, if manually configured, can stop SQL Server from starting. Test the certificate on a non-production copy, and keep the previous thumbprint to put back. If SQL Server will not start, Microsoft's page lets you select another certificate or remove it from use so SQL Server falls back to a self-generated one.
Name not in the certificate. Reissue with the missing names in the SAN. For an availability group, Microsoft's examples include every replica's host name and FQDN and the listener names, and say certificates must be reissued and re-imported when replicas are added. If you cannot reissue yet, Microsoft describes HostNameInCertificate=<name in the certificate> in the connection string. It changes the name the client expects; it does not skip chain or expiry checks.
Risk: reissuing the certificate means selecting it and restarting the SQL Server service, which drops every connection; schedule it as in the step above and keep the previous thumbprint to put back. Setting HostNameInCertificate changes what the client accepts as the server's name, so use only a name that is in the certificate. To back out, remove the keyword from the connection string.
Issuer not trusted by the client. Install the root and intermediate certificates on every client host or container. Microsoft's note: an enterprise certificate is not automatically trusted inside a Linux container or on a separate developer machine.
Risk: installing a root or intermediate certificate widens what that client trusts: the client will accept any certificate issued by that authority for any purpose the store allows. Install only the issuing authority of your SQL Server certificate, obtained from your CA administrator, and never a certificate you cannot trace to your own CA. To back out, remove that certificate from the client's certificate store.
Certificate expired. Renew it, select the renewed certificate in Configuration Manager, restart the SQL Server service, then check the client clock.
Disruptive step: the restart drops every connection and interrupts every application. If SQL Server does not start with the renewed certificate, select the previous certificate or remove the selection, as Microsoft's page describes, so SQL Server falls back to a self-generated certificate.
Pinning. ServerCertificate=<path> compares the server's certificate with a file you supply (PEM, DER or CER). Microsoft says to keep TrustServerCertificate=false and to update the pin whenever the server certificate is renewed.
Risk: a pinned file that no longer matches the server's certificate makes every connection using that string fail, for example the day the server certificate is renewed. To back out, remove ServerCertificate from the connection string or replace the pin file with the new certificate.
Disruptive step: TrustServerCertificate=true. Microsoft's caution is that it "disables server identity validation with Mandatory" and that it should not be deployed "as a production fix for certificate errors". The connection stays encrypted but the client no longer checks who it is talking to. To back out, remove the keyword and fix the certificate.
Do not set Encrypt=false to escape. Microsoft states that Optional "isn't a remedy for certificate errors" and can leave data unencrypted. It also says a server that forces encryption still validates the certificate unless TrustServerCertificate is set.
Confirm the fix
- Connect from the failing client with
Encrypt=true;TrustServerCertificate=falseand the real connection string. - Run the
sys.dm_exec_connectionsquery from the server and confirm the application's session shows TRUE. - Confirm the error log no longer reports the self-generated certificate at the next restart.
Example (illustrative): six applications on CONTOSO servers use sql01.contoso.local. Four of them (4 of 6, or 66.7%) are upgraded to Microsoft.Data.SqlClient 4.0 or later and fail. The two others use an older driver and keep working, because they did not validate the certificate. The error log on sql01 carries the self-generated certificate line. The administrator has the CA issue a certificate with sql01.contoso.local and sql01 in the SAN, selects it in Configuration Manager in a maintenance window, and restarts. The four applications reconnect with no connection string change.
What to watch afterwards
- Track certificate expiry dates. SQL Server checks validity only at configuration time and keeps running after the date, but Microsoft notes some clients check on every connection.
- When replicas are added to an availability group, reissue certificates with the new names.
- Before upgrading a driver in another application, search its connection strings for
TrustServerCertificate=trueandEncrypt=false; each is a certificate fault being hidden.
Read next
Related articles you may want next.
- TroubleshootingSQL Connection Pool Timeout: Find Leaked or Long-Held ConnectionsDistinguish pool acquisition from login or command timeout and identify why connections are unavailable.Read article
- HostingExpiring certificates and secrets that silently break hosted applicationsHow to inventory TLS certificates, client credentials and application secrets before they lapse in steady-state hosted production—not only after an outage.Read article
- TroubleshootingTLS handshake failure: no shared protocol or cipher, read the s_client error and the Schannel eventsslv3 alert handshake failure, no protocols available or Schannel 36874: prove which side lacks a shared TLS version or cipher, fix it and confirm.Read article
Risks and limits
These commands have not been run or lab-tested. Microsoft's pages do not print the exact message text that every driver shows, so match on the cause. KeySpec and certificate requirements apply to SQL Server on Windows; Linux uses different TLS settings. Strict encryption needs SQL Server 2022 or later, and Microsoft says TrustServerCertificate has no effect in that mode.
A certificate is only as good as its private key handling. Do not copy private keys between servers casually, and do not leave a TrustServerCertificate=true workaround in a production string without a dated plan to remove it.
Sources
- What's New in Microsoft.Data.SqlClient — Microsoft Learn, page dated 2026-10-23, accessed 18 November 2026
- Encryption and Certificate Validation in Microsoft.Data.SqlClient — Microsoft Learn, page dated 2026-09-29, accessed 18 November 2026
- SqlConnection.ConnectionString Property (Microsoft.Data.SqlClient) — Microsoft Learn, date not shown, accessed 18 November 2026
- Encrypt Connections by Importing a Certificate — Microsoft Learn, page dated 2025-12-02, accessed 18 November 2026
- Certificate Requirements for SQL Server — Microsoft Learn, page dated 2026-03-03, accessed 18 November 2026
- "The certificate chain was issued by an authority that is not trusted" error after upgrading SNAC applications — Microsoft Learn, page dated 2026-09-03, accessed 18 November 2026
This article was originally published on .