-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
disable sending NT Authority in TLS handshake if specific trust was specified #60988
Conversation
Tagging subscribers to this area: @dotnet/ncl, @vcsjones Issue DetailsWhen Windows sends trusted CA list in handshake it by default includes To deal with it, I added explicit Since this is done on credential handle, we need to also update the caching logic to not mingle that case with others. We don't have any automated tests since this still depends on Windows registry setting. I did manual tests and verified that the fixes #60949
|
src/libraries/System.Net.Security/src/System/Net/Security/SecureChannel.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Give in to the null conditional operator, @wfurt! :)
LGTM either way.
src/libraries/System.Net.Security/src/System/Net/Security/SecureChannel.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Security/src/System/Net/Security/SecureChannel.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Security/src/System/Net/Security/SslStreamPal.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Security/src/System/Net/Security/SslStreamPal.Windows.cs
Outdated
Show resolved
Hide resolved
The problem with the null conditional operator is that pesky literal `== true' at the end to force the type to bool. The brevity is better but the clarity is poor imo. |
I don't really care one way or other. Perhaps @stephentoub or @geoffkizer can chime in with preference. |
Small preference for the null conditional, but either way is ok. |
Co-authored-by: Cory Nelson <phrosty@gmail.com>
I agree with this. I always find it weird to see "== true" because normally it's unnecessary. It makes me have to stop and think about what's going on. An alternative that still uses the null conditional operator, but doesn't use "== true", is: bool sendTrustedList = _sslAuthenticationOptions.CertificateContext!.Trust?._sendTrustInHandshake ?? false; I prefer this slightly, since the use of "?? false" instead of "== true" makes it obvious that you're handling the null case. Also, for the reverse case where you want to treat null as true, "?? true" seems much clearer to me than "!= false", which makes my head hurt even more than "== true". That doesn't apply here though. |
I was thinking about it more and I like this best @geoffkizer. It is basically use "this" or "default". |
/backport to release/6.0 |
Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1469614283 |
When Windows sends trusted CA list in handshake it by default includes
NT Authority
as special case.I'm not sure if anybody depends on it but it seems to break some use cases with new API from #45456.
Particularly attempt to send empty trust list seems to break .NET clients when only
NT Authority
is present.That may be issue with the client selection but we don't have control over all of them.
To deal with it, I added explicit
SCH_CRED_NO_SYSTEM_MAPPER
flag to suppress that channel behavior whenSslCertificateTrust
is provided andsendTrustInHandshake
is set totrue
. (SslStreamPal.Windows.cs)Alternatively, we could set it always but I'm concern about backward compatibility. (
SslCertificateTrust
was introduced in 6.0 so changing it there should be ok)Since this is done on credential handle, we need to also update the caching logic to not mingle that case with others.
We don't have any automated tests since this still depends on Windows registry setting. I did manual tests and verified that the
NT Authority
is not in the CA list as well as pointing to empty certificate store sends empty list.fixes #60949