Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

use ROSpan in SslStreamCertificateContext #83485

Merged
merged 2 commits into from
Mar 29, 2023
Merged

Conversation

wfurt
Copy link
Member

@wfurt wfurt commented Mar 15, 2023

contributes to #67552 and #72226.
If we want to make it public, we should probably make the intermediate certificates immutable.
This change does it to make sure it would work OK.
Since the API is not really public I would probably move forward as preparation.

@ghost
Copy link

ghost commented Mar 15, 2023

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

Issue Details

contributes to #67552 and #72226.
If we want to make it public, we should probably make the intermediate certificates immutable.
This change does it to make sure it would work OK.
Since the API is not really public I would probably move forward as preparation.

Author: wfurt
Assignees: wfurt
Labels:

area-System.Net.Security

Milestone: -

foreach (X509Certificate2 ca in intermediates)
{
collection.Add(ca);
}
Copy link
Member

Choose a reason for hiding this comment

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

This could be slower if we expected a lot of certs. I assume we don't?

Copy link
Member Author

Choose a reason for hiding this comment

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

typically this would be 1-3 items. I was looking at #1530 but it did not seems like I can use the AddRage for generic collection. We actually allocate it just to make the export easy e.g. produce the Pkcs12 blob. If needed we may suck in some crypto primitives directly.

Copy link
Member

Choose a reason for hiding this comment

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

Should be fine as you have it.

Copy link
Member

Choose a reason for hiding this comment

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

Have we considered adding AddRange(RoS) overload into X509Certificate2Collection if we're introducing RoS type on SslStreamCertificateContext?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure that would make measurable improvement. There was some discussion on the issue linked above.
If anything I would push to avoid allocation of the collection.

@@ -85,7 +85,7 @@ public static MsQuicSafeHandle Create(QuicServerConnectionOptions options, strin
}

X509Certificate? certificate = null;
X509Certificate[]? intermediates = null;
ReadOnlySpan<X509Certificate2> intermediates = ReadOnlySpan<X509Certificate2>.Empty;
Copy link
Member

Choose a reason for hiding this comment

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

Can you also switch certificate to X509Certificate2? I don't like the asymmetry here, it think we should decide and stick with one type.

Also would default look better than ReadOnlySpan<X509Certificate2>.Empty ?

Copy link
Member

Choose a reason for hiding this comment

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

We should prefer X509Certificate2 where possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

that one is tricky. Several of the underlying types in callbacks is X509Certificate for historical reasons. So we are possibly up to casting and cast exceptions. I'm not sure if it is worth it since all we do is serialization to MsQuic.

Copy link
Member Author

Choose a reason for hiding this comment

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

BTW as far as the default I have no stone preference. The Empty span seems more explicit but either one should work

foreach (X509Certificate2 ca in intermediates)
{
collection.Add(ca);
}
Copy link
Member

Choose a reason for hiding this comment

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

Have we considered adding AddRange(RoS) overload into X509Certificate2Collection if we're introducing RoS type on SslStreamCertificateContext?

@wfurt
Copy link
Member Author

wfurt commented Mar 29, 2023

I will merge this as work-in-progress. There will be opportunity to do more touches if/when #72226 is approved.
All test failures fall to know-issue list.

@wfurt wfurt merged commit 384d4bd into dotnet:main Mar 29, 2023
@wfurt wfurt deleted the CertificateContext branch March 29, 2023 03:06
@ghost ghost locked as resolved and limited conversation to collaborators Apr 28, 2023
@karelz karelz added this to the 8.0.0 milestone May 27, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants