-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Update System.Net.* unit tests to react to SYSLIB0057 obsoletion #104487
Conversation
Tagging subscribers to this area: @dotnet/ncl |
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.
LGTM
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.
LGTM
I think the test failure is related to this change.
we used to have this problem and @bartonjs suggested to regenerate PFX file and that fixed it. |
and the original runtime issue #58927 |
Most definitely... but in ways that avoid the need to regenerate PFXes.
I've heard reports elsewhere of CI machines having issues talking to the LSA, which seems to be an OS bug (that should have been fixed this week... maybe we don't have patches installed yet?) |
If this is LSA problem we should see failures in other branches. AFAK we did not see failures like this on |
No, we don't see those. I wanted to look into these but I did not yet found time to do it. |
There is seems to be a distinct difference in behavior when using one loading method over the other, the failure is pretty reproducible on my dev machine, but only when I run entire test suite, when I run affected tests (even test classes) in isolation, the issue disappears. Schannel traces suggest that something unexpected happens during InitializeSecurityContext which leads to I will see if I can reduce the repro to something manageable which we can pass to Schannel folks. |
Huh. I'm really curious as to what's going on here. Private key lifetime did get simplified/normalized during the change, but that would be "before/after", not "old way/new way" (the older APIs still have the new key lifetime changes). When loading
None of those differences make sense to me as a long-term problem... they'd either be a problem, or not. A long-term problem sounds like lifetime management; which could be that somewhere you're doing |
That shouldn't be the case, the common test code keeps static references to the certificates once leaded, and gives out cloned handles. What I stumbled upon on the Schanel logs are suspicious nullrefs when calculating the CertificateVerify message both provider and key handle being null is unique to the failing case. |
I suspect this is related to the provider... at least that was the case last time. And selecting "wrong" one TLS 1.3 fails to load algorithms it needs. |
When using the new certificate loader (and not specifying PreserveProviderName), the private key should always be loaded into the Microsoft Software KSP in CNG; which should be the best supported of all key providers. |
I don't see any member called Lines 280 to 308 in d4fe4a7
and https://learn.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-pfximportcertstore documentation, it may be the case that we are missing @bartonjs, When I add the flag, the test error seems to disappear. Should it be present always or just under specific conditions? I don't se corresponding member in |
Sorry, PreserveStorageProvider
Based on testing in the past, a key with no provider name gets loaded into CNG. But, if you're seeing a behavioral change, perhaps something has changed, or it was more nuanced than I thought. It's definitely not a thing we want to expose through X509KeyStorageFlags. It reads like it's a fine thing to always pass, so let's just always pass it. |
We should be able to get the provider from the kay, right @bartonjs? e.g. we can dump it for the failed test cases and see where the key was loaded. |
|
Added the test, and, yep, I'm wrong. It looks like the "improved" loader is loading things into the CAPI "Microsoft Base Cryptographic Provider v1.0". I'm surprised the universe isn't exploding. |
No known failures anymore, we can ship it. |
…net#104487) * Update System.Net.* to react to SYSLIB0057 obsoletion * react to changes in System.Net.WebSockets.Client.Wasm.Tests.csproj --------- Co-authored-by: Tomas Weinfurt <[email protected]> Co-authored-by: Radek Zikmund <[email protected]> Co-authored-by: Jeremy Barton <[email protected]> Co-authored-by: Radek Zikmund <[email protected]>
In #104165 most
X509Certificate
andX509Certificate2
constructors were obsoleted. Since this affected a large number of unit tests across the entire code base, unit tests initially suppressed the obsoletion warning.The pull request changes the unit tests for
System.Net.*
to use the new certificate loader, where appropriate. Some places suppress the obsoletion as they appeared to be specifically testing behaviors and classes, like anX509Certificate
instead of anX509Certificate2
.