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

[release/5.0] fix SslStreamCertificateContext.Create with partial certificate chain #46904

Merged
merged 1 commit into from
Jan 14, 2021

Conversation

wfurt
Copy link
Member

@wfurt wfurt commented Jan 13, 2021

this is port of #46664 to 5.0 branch
Fixes #46654
reported by customer originally in dotnet/aspnetcore#28584

Customer Impact

Kestrel server cannot be started if the machine is somehow missing the cert forming the root of the certificate chain being used.
This is caused by an out of bound array iteration in runtime code.

Regression?

Users who were previously able to start Kestrel no longer can. (Our API is new in 5.0, but Kestrel now uses it.)

Testing

new test case was added for partial certificate chain.

Risk

Low. The fix corrects how we iterate over the array representing the certificate chain so that we don't try to read beyond the array, nor send the wrong certificates.

Details:
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.

@wfurt wfurt added Servicing-consider Issue for next servicing release review area-System.Net.Security labels Jan 13, 2021
@wfurt wfurt added this to the 5.0.x milestone Jan 13, 2021
@wfurt wfurt requested review from bartonjs and a team January 13, 2021 07:22
@wfurt wfurt self-assigned this Jan 13, 2021
@ghost
Copy link

ghost commented Jan 13, 2021

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

this is port of #46664 to 5.0 branch

Customer Impact

Kestrel server cannot be started in certain configurations.
This is caused bu out of bound array iteration in runtime code.

Regression?

not from runtime prospective as this is new 5.0 API.
However, this was adopted by Kestrel and it is causing regression for their users.

Testing

new test case was added for partial certificate chain.

Risk

Low. The fix really is correction for array iteration.

Author: wfurt
Assignees: wfurt
Labels:

Servicing-consider, area-System.Net.Security

Milestone: 5.0.x

@wfurt wfurt changed the title fix SslStreamCertificateContext.Create with partial certificate chain [release/5.0] fix SslStreamCertificateContext.Create with partial certificate chain Jan 13, 2021
@leecow leecow added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Jan 14, 2021
@leecow leecow modified the milestones: 5.0.x, 5.0.3 Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants