-
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
fix SNI handling in quic #55468
fix SNI handling in quic #55468
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @dotnet/ncl Issue DetailsThis is attempt to close functional gap between SslStream and QUIC with focus on server part.
When callback fails or returns fixes #55421
fixes #49587
|
src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicListener.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicConnection.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicListener.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicListener.cs
Outdated
Show resolved
Hide resolved
@nibanks Can you take a look at the issues raised above in the original description here? |
We cannot do that. MsQuic must have the ALPNs so that it can multiplex parallel, independent listeners for the different protocols on the same local port (e.g. HTTP and SMB). |
Could you simply start single listener in this case? It seems unlikely that somebody would run SMB on same port as HTTP server. Running multiple HTTP servers with different policies seems quite common. That can be Kestrel or YARP or any multi-tenant deployment. |
src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicListener.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicListener.cs
Show resolved
Hide resolved
src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicListener.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicListener.cs
Outdated
Show resolved
Hide resolved
if (state.AuthenticationOptions.ServerCertificateSelectionCallback != null) | ||
{ | ||
// ServerCertificateSelectionCallback is synchronous. We will call it as needed when building configuration | ||
connectionConfiguration = SafeMsQuicConfigurationHandle.Create(state.ConnectionOptions, state.AuthenticationOptions, targetHost); |
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.
We probably shouldn't be calling the user's callback on the msquic thread, right?
If we need to do this for now, then that's fine; but we should at least file an issue on this.
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.
ok. We already do that for validation. We can change them both but we would end up with quite a bit more complicated code IMHO. Aside from handling exceptions what are the main drawbacks of running from the event handler?
@geoffkizer this is ready for another round of code review ... |
...Net.Quic/src/System/Net/Quic/Implementations/MsQuic/Interop/SafeMsQuicConfigurationHandle.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicConnection.cs
Outdated
Show resolved
Hide resolved
try | ||
{ | ||
uint status = MsQuicApi.Api.ConnectionStartDelegate( | ||
status = MsQuicApi.Api.ConnectionStartDelegate( |
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.
status = MsQuicApi.Api.ConnectionStartDelegate( | |
uint status = MsQuicApi.Api.ConnectionStartDelegate( |
It shouldn't clash if you put the declaration above next to the SetParamDelegate
as well. They should be within different scopes.
src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicConnection.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicConnection.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicListener.cs
Show resolved
Hide resolved
src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicListener.cs
Show resolved
Hide resolved
Please ignore the |
Aside from direct feedback I did following updates:
handle processing is still messed up. I will address that as separate PR. |
This is attempt to close functional gap between SslStream and QUIC with focus on server part.
This PR has three big chunks:
HTTP/3 requires client to send SNI but we did not send any.
Current code would marshal IP address as string but we would never pass in the target server name.
To fix that I added
QUIC_PARAM_CONN.REMOTE_ADDRESS
. When remote address is set, MsQuic only saves string passed toConnectionStart
as SNI and does not tries to connect to it.I did not see way how to set SNI separately. Perhaps @nibanks can comment but I don't know how to set SNI to separate value for DNS endpoint e.g. if the SNI does not match host one connects to.
Adding support for
ServerCertificateSelectionCallback
and add ability the select different certificates on single listener.This is somewhat straight forward. I decide to delay creation of
SafeMsQuicConfigurationHandle
. Since the callback is synchronous we call it when we get the SNI from client. We will create multiple configurations and there is probably opportunity for caching. SafeHandle should do right thing and release underlying memory when closed.When callback fails or returns
null
for particular SNI we will abort whole Listener and that feels unpleasant.However I feel fixing the error behavior is not in scope of this PR.
fixes #55421