-
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
fix SslStreamCertificateContext.Create with partial chain #46664
Conversation
Tagging subscribers to this area: @dotnet/ncl Issue DetailsWith TrimRootCertificate=false, the old logic would incorrectly increase count when chain.Build() return partial chain. That would later cause ArgumentOutOfRangeException when iterating through the chain certificate collection. Further more, the TrimRootCertificate is swapped. If we want to trim root we need to subtract 2 (e.g. root itself and leaf cert) This will cause wrong number of certificates sent on the wire on Unix. (on Windows all the logic is bolted to OS) To fix this, I refactor the code a little bit. There is no need to invoke the partial chain logic at all if we are going to give whole chain to OS (Windows) I added variant to SslStream_UntrustedCaWithCustomCallback_OK and verified it will expose the ArgumentOutOfRangeException without the fix. fixes #46654
|
src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.cs
Show resolved
Hide resolved
src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs
Outdated
Show resolved
Hide resolved
/backport to release/5.0 |
Started backporting to release/5.0: https://github.com/dotnet/runtime/actions/runs/479577515 |
@wfurt backporting to release/5.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: fix SslStreamCertificateContext.Create with partial chain
Applying: add test with long partial chain
error: sha1 information is lacking or useless (src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0002 add test with long partial chain
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
@wfurt After the 5.02 update, the console example is good, but the web server example still reports an error as follows
|
It was not ported to 5.0 branch yet - see #46654 |
You can try the fix on 6.0/master branch https://github.com/dotnet/installer @sukney |
With TrimRootCertificate=false, the old logic would incorrectly increase count when chain.Build() return partial chain. That would later cause ArgumentOutOfRangeException when iterating through the chain certificate collection.
Further more, the TrimRootCertificate is swapped. If we want to trim root we need to subtract 2 (e.g. root itself and leaf cert) This will cause wrong number of certificates sent on the wire on Unix. (on Windows all the logic is bolted to OS)
To fix this, I refactor the code a little bit. There is no need to invoke the partial chain logic at all if we are going to give whole chain to OS (Windows)
I added variant to SslStream_UntrustedCaWithCustomCallback_OK and verified it will expose the ArgumentOutOfRangeException without the fix.
fixes #46654