Repository navigation
[release/7.0] Fix auth exception stopping QUIC connection listener - #43730
Conversation
I think the behavior is consistent with the documentation. I realize it is not very user-friendly in the case of |
I believe only the |
|
The changed behavior was reaction to dotnet/runtime#72160. Yes, the original issue was about misconfigured listener, but the decision was to expose all errors, not filter for specific ones and swallow the rest. Listener users can do that themselves, at least they have the option now.
Yes, I believe this as well. |
|
While I think that For example, you could even create a callback with A way to avoid this could be to wrap the exception thrown in |
|
Approved for .NET 7 RC2. |
|
@dotnet/aspnet-build Please merge. |
|
@JamesNK Are the test failures expected? |
|
Oh. Tests. I'll take a look. |
| // If the client rejects the connection because of an invalid cert then AcceptConnectionAsync throws. | ||
| // An error thrown inside ConnectionOptionsCallback can also throw from AcceptConnectionAsync. | ||
| // These are recoverable errors and we don't want to stop accepting connections. | ||
| QuicLog.ConnectionListenerAcceptConnectionFailed(_log, ex); |
There was a problem hiding this comment.
An error thrown inside ConnectionOptionsCallback can also throw from AcceptConnectionAsync.
Do exceptions originating from the TlsHandshakeCallbackOptions.OnConnection
get logged at a debug level when we're using the HttpsConnectionMiddleware?
Won't most exception types bubble out through AuthenticateAsServerAsync and get logged as an error by KestrelConnectionOfT? Ideally errors thrown by user code like the OnConnection callback should be logged at a higher level.
This is a fairly low-level API though, and it's best to get the fix in quickly, so I'll approve it either way.
I improved a flaky test. Ready to merge? 🙏 |
Fixes #43723
Description
If an HTTP/3 connection request from a client fails because of an auth issue, e.g. client rejects an invalid server certificate, then the connection listener accept loop stops. This prevents future connections.
Customer Impact
Without this fix, a client can create a request that causes to Kestrel to stop accepting HTTP/3 connections.
Regression?
Maybe. There might have been changes in System.Net.Quic to throw this error. The XML docs on QuicListener.AcceptConnectionAsync have mixed signals about whether this exception should be thrown.
@dotnet/ncl could you confirm that this is expected behavior?
Risk
This fixes this particular error, but I worry about if there are other exceptions that are thrown out of listener accept that would stop the connection accept loop. I'd like to get some advice on @dotnet/ncl on how best to useQuicListener.AcceptConnectionAsync.We should keep listening ifAuthenticationExceptionis thrown. Is there a list ofQuicErrorvalues for which we should continue listening? Or the inverse, whatQuicErrorvalues should stop the accept loop?I think we have certainty from the NCL team on how best to use the QUIC connection listener.
Verification
I'm unsure if it is possible to test this error in a browser manually. A browser HTTP/3 connection only works when the server offers a valid TLS cert; this failure only happens when the TLS cert is invalid.
Packaging changes reviewed?
@Pilchie