Skip to content

[8.0.1 Cherry-pick] Connection: Apply ServerCertificate validation to login-only TLS - #5182

Open
github-actions[bot] wants to merge 2 commits into
release/8.0from
dev/automation/pr-5164-to-8.0.1
Open

github-actions[bot] wants to merge 2 commits into
release/8.0from
dev/automation/pr-5164-to-8.0.1

Conversation

@github-actions

@github-actions github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Cherry-pick of #5164 (34ee446) into release/8.0.

The product change applied cleanly. One follow-up commit fixes the new tests' build on this branch.

Additional change: certificate test adaptation

SqlConnectionCertificateTests used SqlException.EncryptionInfo and SqlServerCertificateValidationErrors, which come from main-only connection-encryption-info work. Removed those two assertions. The remaining assertions still verify that a mismatched pin is rejected before login: fatal error class 20, one pre-login, and zero LOGIN7 packets. release/8.0 already has the required simulated-server test infrastructure.

Testing

  • dotnet build build.proj -t:BuildSqlClient — passed. The unit test project builds.
  • dotnet test src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft.Data.SqlClient.UnitTests.csproj -f net10.0 --filter "FullyQualifiedName~SqlConnectionCertificateTests&category!=failing" — 42/42 passed in each of 2 runs. These tests are .NET-only (#if NET), as on main.

When ServerCertificate is configured and TrustServerCertificate is false, validate the server certificate for login-only TLS negotiated with Encrypt=Optional, before login is sent. A configured certificate with no negotiated TLS now fails instead of being ignored. Matching certificates, TrustServerCertificate and connections without ServerCertificate are unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
github-actions Bot requested a review from a team as a code owner December 3, 2026 19:34
@github-actions github-actions Bot added this to the 8.0.1 milestone Dec 3, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

paulmedynski
paulmedynski previously approved these changes Dec 4, 2026
@paulmedynski
paulmedynski enabled auto-merge (squash) December 4, 2026 13:35
@paulmedynski

Copy link
Copy Markdown
Contributor

/azp run

@paulmedynski paulmedynski moved this from To triage to In review in SqlClient Board Dec 4, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.

SqlException.EncryptionInfo and SqlServerCertificateValidationErrors are not available on release/8.0. The remaining assertions (fatal error class, single pre-login, no LOGIN7) still verify that a mismatched pin is rejected before login.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@paulmedynski

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.

@codecov

codecov Bot commented Dec 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 70.50%. Comparing base (4523605) to head (3c766ee).
⚠️ Report is 5 commits behind head on release/8.0.

Files with missing lines Patch % Lines
...t/src/Microsoft/Data/SqlClient/Parser/TdsParser.cs 92.30% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           release/8.0    #5182      +/-   ##
===============================================
+ Coverage        70.41%   70.50%   +0.09%     
===============================================
  Files              313      313              
  Lines            45808    69774   +23966     
===============================================
+ Hits             32255    49194   +16939     
- Misses           13553    20580    +7027     
Flag Coverage Δ
CI-SqlClient ?
sqlclient-pr 70.50% <92.30%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants