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

TDS8 - Enable retrieval of TLS 1.3 SSL Protocol from SNI on .NET Core #1821

Merged
merged 3 commits into from
Nov 2, 2022

Conversation

lcheunglci
Copy link
Contributor

I ran into a timeout issue during WaitForSSLHandShakeToComplete when I ran .NET Core with TLS 1.3 and noticed a commented-out section where it checks for TLS 1.3 and returning SslProtocols.None. However, I ran into a compile error when uncommenting a check for the ssl protocol while testing .NET Core with TLS1.3 when building the MDS project on .NET standard 2.1 because SslProtocols.Tls13 does not exist. The SslProtocols.Tls13 does exist on .NET Core 3.1 and above, so I added an if-def for it, so that I can get past the timeout issue where the retrieval of the protocol version occurs.

@codecov
Copy link

codecov bot commented Oct 31, 2022

Codecov Report

Base: 71.38% // Head: 71.34% // Decreases project coverage by -0.03% ⚠️

Coverage data is based on head (32deb30) compared to base (20d4c19).
Patch coverage: 5.88% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1821      +/-   ##
==========================================
- Coverage   71.38%   71.34%   -0.04%     
==========================================
  Files         290      290              
  Lines       61236    61251      +15     
==========================================
- Hits        43712    43702      -10     
- Misses      17524    17549      +25     
Flag Coverage Δ
addons 92.38% <ø> (ø)
netcore 74.93% <5.88%> (-0.09%) ⬇️
netfx 69.28% <ø> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
...osoft/Data/SqlClient/TdsParserStateObjectNative.cs 86.77% <0.00%> (-0.93%) ⬇️
.../netcore/src/Microsoft/Data/SqlClient/TdsParser.cs 73.37% <6.66%> (-0.18%) ⬇️
.../src/Microsoft/Data/SqlClient/SNI/SNIMarsHandle.cs 87.89% <0.00%> (-4.49%) ⬇️
.../Data/SqlClient/SNI/SslOverTdsStream.NetCoreApp.cs 47.50% <0.00%> (-4.17%) ⬇️
...rc/Microsoft/Data/ProviderBase/DbConnectionPool.cs 85.63% <0.00%> (-0.59%) ⬇️
...t/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs 72.18% <0.00%> (-0.39%) ⬇️
...netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs 83.44% <0.00%> (-0.33%) ⬇️
...c/Microsoft/Data/SqlClient/TdsParserStateObject.cs 81.50% <0.00%> (-0.08%) ⬇️
...rc/Microsoft/Data/ProviderBase/DbConnectionPool.cs 85.19% <0.00%> (+0.16%) ⬆️
...c/Microsoft/Data/SqlClient/TdsParserStateObject.cs 81.65% <0.00%> (+0.21%) ⬆️
... and 4 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Comment on lines 428 to 437
* This driver does not support this version yet! */
#if NETCOREAPP3_1_OR_GREATER
if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_3_CLIENT) || nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_3_SERVER))
{
protocolVersion = (int)SslProtocols.Tls13;
}*/
}
else if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_2_CLIENT) || nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_2_SERVER))
#else
if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_2_CLIENT) || nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_2_SERVER))
#endif
Copy link
Member

Choose a reason for hiding this comment

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

It's not required to be the first statement in the chain of if-else statements. This additional condition can be added as a else if just for simplification.
Also, the related inline comments won't be valid anymore.

@DavoudEshtehari DavoudEshtehari added this to the 5.1.0-preview2 milestone Oct 31, 2022
@DavoudEshtehari DavoudEshtehari added this to In Progress in SqlClient v5.1 via automation Oct 31, 2022
@@ -425,12 +425,16 @@ internal override uint WaitForSSLHandShakeToComplete(out int protocolVersion)
var nativeProtocol = (NativeProtocols)nativeProtocolVersion;

/* The SslProtocols.Tls13 is supported by netcoreapp3.1 and later
* This driver does not support this version yet!
* This driver does not support this version yet! */
#if NETCOREAPP3_1_OR_GREATER
Copy link
Member

Choose a reason for hiding this comment

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

Since we are not supporting netcoreapp3.1 it should suffice if we just want to check for NETCOREAPP and omit the version.

Suggested change
#if NETCOREAPP3_1_OR_GREATER
#if NETCOREAPP

SqlClient v5.1 automation moved this from In Progress to Review Approved Nov 1, 2022
@JRahnama JRahnama merged commit 146c34e into dotnet:main Nov 2, 2022
SqlClient v5.1 automation moved this from Review Approved to Done Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants