Skip to content

[7.0] Fix macOS TLS certificate validation unit tests - #5056

Merged
cheenamalhotra merged 1 commit into
release/7.0from
dev/cheena/tls-unit-test-investigation
Nov 12, 2026
Merged

cheenamalhotra merged 1 commit into
release/7.0from
dev/cheena/tls-unit-test-investigation

Conversation

@cheenamalhotra

Copy link
Copy Markdown
Member

Description

Add the Server Authentication EKU to the generated test certificates. On macOS, .NET 8/9 otherwise report RemoteCertificateNameMismatch because Apple SSL policy rejects the missing EKU, even when the DNS SAN matches.

Test-only change; production validation, assertions, public APIs, and documentation are unchanged.

Issues

Follow-up to #4908.

Testing

Reproduced four failing cases on macOS/.NET 8 before the fix. After the fix, all 33 certificate-validation cases pass on each of .NET 8, 9, and 10 (99 passed, none skipped).

Used the installed SDK 10.0.401 explicitly because the pinned 10.0.109 SDK is unavailable locally:

dotnet /usr/local/share/dotnet/sdk/10.0.401/dotnet.dll test src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft.Data.SqlClient.UnitTests.csproj --configuration Release --no-restore --filter 'FullyQualifiedName~SniCommonValidateSslServerCertificateTest' --verbosity quiet

Result: passed on all three target frameworks. Windows/Linux runs and SQL Server integration tests were not run locally; only the test certificate fixture changed.

  • Tests added or updated
  • Public API changes documented (not applicable; test-only)
  • Verified against reported failure
  • Ensure no breaking changes introduced

Guidelines

Please review the contribution guidelines before submitting a pull request:

Add the Server Authentication EKU so macOS SSL policy accepts the test certificate on .NET 8 and 9.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@cheenamalhotra
cheenamalhotra requested a review from a team as a code owner November 12, 2026 21:48
Copilot AI balanced review requested due to automatic review settings November 12, 2026 21:48
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Nov 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the test-only certificate EKU update for macOS TLS compatibility.

No open issues 🎉

What changed in this PR

This test-only follow-up to #4908 updates generated certificates to satisfy macOS TLS policy, allowing the managed SNI certificate-validation tests to exercise hostname validation as intended.

Changes:

  • Adds an explicit Server Authentication enhanced key usage (EKU) extension to self-signed test certificates.
  • Leaves production validation, test assertions, and public APIs unchanged.
File Description
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​Microsoft/​Data/​SqlClient/​ManagedSni/​SniCommonValidateSslServerCertificateTest.cs Adds the Server Authentication EKU to the shared certificate fixture for macOS compatibility.

Review effort: Balanced

@cheenamalhotra cheenamalhotra added the Area\Tests Issues that are targeted to tests or test projects label Nov 12, 2026
@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.81%. Comparing base (75ec803) to head (a8943af).
⚠️ Report is 3 commits behind head on release/7.0.

❗ There is a different number of reports uploaded between BASE (75ec803) and HEAD (a8943af). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (75ec803) HEAD (a8943af)
CI-SqlClient 1 0
Additional details and impacted files
@@               Coverage Diff               @@
##           release/7.0    #5056      +/-   ##
===============================================
- Coverage        73.59%   66.81%   -6.79%     
===============================================
  Files              296      291       -5     
  Lines            43521    66427   +22906     
===============================================
+ Hits             32030    44382   +12352     
- Misses           11491    22045   +10554     
Flag Coverage Δ
CI-SqlClient ?
PR-SqlClient-Project 66.81% <ø> (?)

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.

@cheenamalhotra cheenamalhotra added this to the 7.0.4 milestone Nov 12, 2026
@cheenamalhotra
cheenamalhotra enabled auto-merge (squash) November 12, 2026 23:08
@cheenamalhotra
cheenamalhotra merged commit 519bc8c into release/7.0 Nov 12, 2026
290 of 291 checks passed
@cheenamalhotra
cheenamalhotra deleted the dev/cheena/tls-unit-test-investigation branch November 12, 2026 23:14
@github-project-automation github-project-automation Bot moved this from To triage to Done in SqlClient Board Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area\Tests Issues that are targeted to tests or test projects

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants