Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix | Fixed GenerateSspiClientContext to retry negotiation with default port #2559

Conversation

arellegue
Copy link
Contributor

@arellegue arellegue commented Jun 10, 2024

This PR fixes Issue #2394

When an application is targeting .Net 6.0, the application connects to the database successfully from Linux because the application is using System.Net.Security.NegotiateStreamPal.Unix.InitializeSecurityContext function which is retrying the negotiation with default port number 1433. However, when the application is targeting .Net8.0, the application fails to connect to the database from Linux because the newer implementation, MDS.SSPI.NegotiateSSPIContextProvider, did not retry with default port number. This issue is fixed in this PR.

@arellegue arellegue marked this pull request as ready for review June 10, 2024 19:11
Copy link
Member

@DavoudEshtehari DavoudEshtehari left a comment

Choose a reason for hiding this comment

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

@David-Engel Do you see any straight forward solution to add unit test for this case?

@DavoudEshtehari DavoudEshtehari added the 🐛 Bug! Something isn't right ! label Jun 10, 2024
@DavoudEshtehari DavoudEshtehari added this to the 6.0-preview1 milestone Jun 10, 2024
@David-Engel
Copy link
Contributor

Do you see any straight forward solution to add unit test for this case?

Straightforward, no. It would be an edge case that would require specific environment setup and conditional checking on the test. I'd rather just get the fix in than make it wait for a test.

@arellegue arellegue changed the title Fix | Fix GenerateSspiClientContext to retry negotiation with default port Fix | Fixed GenerateSspiClientContext to retry negotiation with default port Jun 10, 2024
Copy link

codecov bot commented Jun 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.80%. Comparing base (348ae2e) to head (3697d08).
Report is 1 commits behind head on main.

Current head 3697d08 differs from pull request most recent head 3e413c5

Please upload reports for the commit 3e413c5 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2559      +/-   ##
==========================================
- Coverage   73.01%   72.80%   -0.21%     
==========================================
  Files         311      311              
  Lines       61694    61694              
==========================================
- Hits        45043    44916     -127     
- Misses      16651    16778     +127     
Flag Coverage Δ
addons 92.88% <ø> (ø)
netcore 77.18% <ø> (-0.17%) ⬇️
netfx 70.41% <ø> (-0.18%) ⬇️

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

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

@arellegue arellegue merged commit 3f0c4b1 into dotnet:main Jun 11, 2024
129 of 147 checks passed
deepaksa1 added a commit to deepaksa1/SqlClient that referenced this pull request Jul 22, 2024
* Updating Azure.Identity version to 1.11.3 (dotnet#2526)

* Fix | Clone of SqlConnection should include AccessTokenCallback (dotnet#2525)

* Enhancement | Add trace logs for packet size (dotnet#2522)

* Merged PR 4583: eng | Fix policheck errors.

Fix policheck errors.

Sample pipeline run which did not have policheck errors:

https://sqlclientdrivers.visualstudio.com/ADO.Net/_build/results?buildId=88114&view=sariftools.scans.build-tab

Related work items: #30279

* Doc | Fix SNI dependencies of 5.1 and 5.2 release notes (dotnet#2537)

* Change | Separate tests for NetFx and NetCore - NetFx-Only Connection String Properties (dotnet#2466)

* Adding TransparentNetworkIpResolution to list of unsupported on platform connection string error messages
Splitting unit test for netfx-only connection string properties such that test does not fail on netcore

* Remove DeprecatedSynonymCount since referencing the unsupported array is not possible

* Fix | Enhance certificate validation (dotnet#2487)

* Hotfix v5.2.1 Release notes (dotnet#2534)

* Improve AccessTokenCallback sample code (dotnet#2543)

* Merged PR 4621: eng | Fix policheck

* Fix | Adjust path for .AssemblyAttributes in obj folder (dotnet#2550)

* Fix | Fixed GenerateSspiClientContext to retry negotiation with default port (dotnet#2559)

* Strong typed diagnostics (dotnet#2226)

* Fix | Replaced System.Runtime.Caching with Microsoft.Extensions.Caching.Memory (dotnet#2493)

* Add | Add SourceLink translation (dotnet#2552)

* Add | Cache TokenCredential objects to take advantage of token caching (dotnet#2380)

* Merged common code base for SqlUtil.cs (dotnet#2533)

* Add scope trace for GenerateSspiClientContext (dotnet#2497)

* Address conflicts (dotnet#2562)

* Addressing conflict (dotnet#2560)

* Merge SqlColumnEncryptionCertificateStoreProvider (dotnet#2521)

* Add | No-op if engineedition is 6 or 11 due to lack of support for ASSEMBLYPROPERTY function (dotnet#2593)

* Change | Remove some unneeded references and update Azure.Identity (dotnet#2577)

* Add test for issue 2456 (dotnet#2457)

* Merged common code base for AlwaysEncryptedKeyConverter (dotnet#2538)

* Merged AlwaysEncryptedKeyConverter.CrossPlatform and AlwaysEncryptedKeyConverter.Cng.

* 3 Small Changes (dotnet#2594)

* * Port sqlclientx datasource changes
* Remove link to missing nuget.config file
* Remove root namespaces from sqlclient csproj files

* Test to see if namespace changes are breaking the pr build

* Reinstate removing the root namespace and fix resource filename generation

* Test fixes to accommodate recent infra changes (dotnet#2646)

* Test fixes to accomodate recent infra changes

* Fix - Don't error when using infinte connect timeout and Entra auth (dotnet#2651)

* eng | Add delay signed to official builds (dotnet#2653)

* eng | Initial YAML CI pipeline (dotnet#2575)

* Fix | Fix decrypt failure to drain data (dotnet#2618)

* [Scheduled Run] Localized resource files from OneLocBuild

* eng | Add Delay sign to ref csprojs (dotnet#2684)

* [Scheduled Run] Localized resource files from OneLocBuild

* [Scheduled Run] Localized resource files from OneLocBuild

---------

Co-authored-by: Javad Rahnama <[email protected]>
Co-authored-by: David Engel <[email protected]>
Co-authored-by: Aris Rellegue <[email protected]>
Co-authored-by: DavoudEshtehari <[email protected]>
Co-authored-by: Benjamin Russell <[email protected]>
Co-authored-by: Aris Rellegue <[email protected]>
Co-authored-by: dauinsight <[email protected]>
Co-authored-by: Scott Addie <[email protected]>
Co-authored-by: Daniel Au <[email protected]>
Co-authored-by: Wraith <[email protected]>
Co-authored-by: SqlClient Azure DevOps <[email protected]>
Co-authored-by: Edward Neal <[email protected]>
Co-authored-by: Erik Ejlskov Jensen <[email protected]>
Co-authored-by: David Engel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug! Something isn't right ! netcore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Server principle name lookup does not include port number in the name
3 participants