Clarification on MSOLEDBSQL19 Behavior with TrustServerCertificate=True

Abhishek Modi (amodi) 20 Reputation points
2026-07-13T09:22:07.6666667+00:00

Hello Team,

We are currently using the MSOLEDBSQL19 driver on Windows systems and would like to better understand its connection behavior related to encryption and certificate validation.

While testing SQL Server connectivity, we observed that a connection can be established when TrustServerCertificate=True is specified, even when the following prerequisites have not been explicitly performed on the client or server:

  1. Installing a CA-trusted TLS certificate on the SQL Server.
  2. Importing the server's self-signed certificate into the client machine's trusted certificate store.

Our understanding is that TrustServerCertificate=True should bypass certificate chain validation, allowing an encrypted connection to proceed even if the certificate is not trusted. However, we would like clarification on the following:

  • If neither of the above prerequisites is configured on the server (i.e., no CA-trusted TLS certificate is installed and the server certificate is not trusted by the client), will a connection still be established when using MSOLEDBSQL19 with TrustServerCertificate=True specified in the connection string?
  • If the connection succeeds, could you please explain the underlying behavior of MSOLEDBSQL19 and how the driver handles encryption and certificate validation in this scenario?
  • Which certificate, driver, or provider behavior enables the connection to be established?
  • Are there any changes in MSOLEDBSQL19 compared to previous drivers/providers regarding certificate validation and encryption?
  • Could you explain the rationale behind the additional recommendations to install a trusted certificate or import the server certificate, given that SQL Server appears to allow the connection when TrustServerCertificate=True is specified?

Any clarification on the underlying behavior and best practices would be greatly appreciated.

Thanks,

Abhishek Modi

SQL Server Database Engine
0 comments No comments

4 answers

Sort by: Most helpful
  1. sudhir kumar 0 Reputation points
    2026-08-19T13:31:03.5966667+00:00

    When using MSOLEDBSQL19, setting

    TrustServerCertificate=True forces the client to bypass certificate chain and host name validation, allowing an encrypted connection over self-signed or untrusted server certificates. Unlike older driver versions, MSOLEDBSQL19 evaluates this property in all encrypted scenarios, but it does not disable encryption itself.

    Was this answer helpful?

    0 comments No comments

  2. Erland Sommarskog 136.7K Reputation points MVP Volunteer Moderator
    2026-07-13T21:37:45.61+00:00

    Deepesh has already answered your questions, but I like to fill in that this is nothing that is unique to the OLE DB driver, but this is a change that Microsoft has done across the board with all drivers. That is, all drivers now default to require an encrypted connection by a trusted certificate

    Trusting the server certificate is acceptable if you are connecting to an SQL Server instance on the same machine - the risk for a man-in-the-middle attack is minimal. Likewise it can be OK, if there is no real production data on the server. But for a connections to a production system with sensitive data, you should have a trusted certificate in place.

    Also, note that depending on which OLE DB interface you use, it is either TrustServerCertificate=yes or Trust Server Certificate=true. (The fact that there are two sets of connection keywords are just plain lunacy.)

    Was this answer helpful?


  3. Deepesh Dhake 835 Reputation points
    2026-07-13T16:38:19.7933333+00:00

    1.Will the connection succeed with no certificate configured anywhere?

    Yes. SQL Server generates a self-signed certificate at startup if none is installed, so there's always something to complete the TLS handshake with. With TrustServerCertificate=True, MSOLEDBSQL19 skips chain and hostname validation, so the handshake completes and the session is genuinely TLS-encrypted.

    2.What enables this behavior?

    The combination of the server's auto-generated self-signed certificate and the driver suppressing validation. Encryption still happens but identity verification doesn't.

    3.What changed in MSOLEDBSQL19?

    The default for Encrypt changed from no to yes/Mandatory, and TrustServerCertificate was decoupled from Encrypt, previously, if Encrypt was no, certificates weren't validated regardless of the TrustServerCertificate setting. Validation now also triggers when either side negotiates encryption, not just the client. New values (Optional/Mandatory/Strict) and the HostNameInCertificate keyword were added. Strict uses TDS 8.0 and always validates, though a ServerCertificate property (19.2+) allows pinning a specific certificate, and it requires Encrypt=Strict.

    4.Why install a trusted certificate if the connection works anyway?

    TrustServerCertificate=True gives you encryption without authentication. Microsoft's documentation warns that trusting the server certificate can leave you vulnerable to man-in-the-middle attacks, and recommends setting it back to FALSE once a verifiable certificate is deployed. An attacker on the network path can present their own certificate and your client will accept it. Best practice: CA-issued certificate on the server, Encrypt=Mandatory (or Strict on SQL 2022+), TrustServerCertificate=False.

    Was this answer helpful?

    0 comments No comments

  4. AI answer

    2026-07-13T09:22:29.6133333+00:00

    Yes. With MSOLEDBSQL 19, a connection can still be established with encryption when TrustServerCertificate=True is used, even if the server does not have a CA-signed certificate and the client does not trust the server certificate.

    How it works depends on the encryption mode:

    1. If encryption is negotiated or required and TrustServerCertificate=True is in effect, the connection can proceed without validating the server certificate.
    2. In that case, the session can still be encrypted, but certificate chain trust and hostname validation are bypassed.
    3. This behavior is why the connection can succeed even when the certificate is self-signed or not present in the client trusted root store.

    For MSOLEDBSQL 19 specifically:

    • TrustServerCertificate was not removed in version 19.
    • Version 19 evaluates TrustServerCertificate in all encrypted scenarios.
    • A key change from version 18 is this case: when the client sets Encrypt=no but the server forces encryption, version 18 ignored Trust Server Certificate, while version 19 evaluates it.
    • Because of that change, version 19 clients using default settings can fail when the server forces encryption and uses an untrusted certificate, unless Trust Server Certificate is updated or a trusted certificate is used.

    The underlying behavior is not that SQL Server waives trust requirements on its own. The driver is what allows the connection by choosing to encrypt the channel while skipping certificate validation when TrustServerCertificate=True applies.

    The certificate used is still the certificate presented by SQL Server during TLS negotiation. The difference is that, with TrustServerCertificate=True, the driver accepts that certificate without requiring it to chain to a trusted CA.

    Why trusted certificates are still recommended:

    • A valid CA-signed certificate provides certificate validation.
    • The certificate must match the server FQDN when validation is enforced.
    • The certificate must be trusted by the client system.
    • This is the secure configuration and is required in stricter modes.

    For example, when Encrypt=True or Encrypt=Mandatory and TrustServerCertificate=Yes is not used, the connection requires a valid CA-signed certificate, FQDN match, and trust on the client. When Encrypt=Strict, TrustServerCertificate is not supported; a valid trusted certificate is required.

    So the recommendation to install a trusted certificate or import the server certificate exists because TrustServerCertificate=True is a compatibility/convenience setting that allows encrypted connectivity without certificate validation, whereas trusted certificates provide actual server identity validation and stronger security.

    One more MSOLEDBSQL 19 detail: keyword format differs by interface:

    • Provider connection strings: TrustServerCertificate=yes;
    • IDataInitialize connection strings: Trust Server Certificate=yes;

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.