-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Support getting client certificate in Http/3 #35016
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
Conversation
src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionContext.FeatureCollection.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionContext.FeatureCollection.cs
Outdated
Show resolved
Hide resolved
...rvers/Kestrel/Transport.Libuv/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.csproj
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionContext.FeatureCollection.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionContext.FeatureCollection.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionContext.FeatureCollection.cs
Outdated
Show resolved
Hide resolved
|
Add a test to Transports.Quic.Tests in connection tests file. Create a client connection with a client certificate specified, accept connection on the server, get feature from server connection, assert cert. Also create a stream on the connection and get feature plus assert again. |
src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionContext.FeatureCollection.cs
Outdated
Show resolved
Hide resolved
...Servers/Kestrel/Transport.Quic/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.csproj
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionContext.FeatureCollection.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionContext.FeatureCollection.cs
Outdated
Show resolved
Hide resolved
|
|
||
| var serverConnection = await connectionListener.AcceptAndAddFeatureAsync().DefaultTimeout(); | ||
|
|
||
| /*var tlsFeature = serverConnection.Features.Get<ITlsConnectionFeature>(); |
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.
@JamesNK the ITlsConnectionFeature and IProtocolErrorCodeFeature are not available on the serverConnection, only the serverStream. These tests also only try to get the IProtocolErrorCodeFeature from the stream - is that expected?
aspnetcore/src/Servers/Kestrel/Transport.Quic/test/QuicConnectionContextTests.cs
Line 335 in 709038b
| serverStream.Features.Get<IProtocolErrorCodeFeature>().Error = (long)Http3ErrorCode.RequestRejected; |
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.
ITlsConnectionFeature and IProtocolErrorCodeFeature should be available on the connection.
Lines 29 to 33 in 45222c1
| private void InitializeFeatures() | |
| { | |
| _currentIProtocolErrorCodeFeature = this; | |
| _currentITlsConnectionFeature = this; | |
| } |
Have you debugged into what happens when Get is called?
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.
If these features are not available on the connection, why does this test code work?
aspnetcore/src/Servers/Kestrel/Transport.Quic/test/QuicConnectionContextTests.cs
Line 335 in 709038b
| serverStream.Features.Get<IProtocolErrorCodeFeature>().Error = (long)Http3ErrorCode.RequestRejected; |
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.
That's getting the feature from the stream - the code above at line 524 does not have either ITlsConnectionFeature or IProtocolErrorCodeFeature available in the featureCollection of the connection.
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.
Have you debugged into what happens when Get is called?
This is weird - under the debugger, I get the feature and it has the ClientCertificate set, and the test passes. But when run normally, the test fails at line 526 at Assert.NotNull(tlsFeature.ClientCertificate)...
|
Should we also add an end-to-end test here? ** Edit ** Neverminded, I'll probably have to add that later when we enable passing ClientCertificateMethod through to quic. |
…Context.FeatureCollection.cs Co-authored-by: Chris Ross <[email protected]>
…Context.FeatureCollection.cs Co-authored-by: Chris Ross <[email protected]>
4339b64 to
17f4ca1
Compare
|
Updated the test and got it to pass. Also, I changed it to test a server stream that is accepted from the client - this is a request stream - rather than create one to the client. Also, rebased. |
What was I doing wrong before? |
src/Servers/Kestrel/Transport.Quic/test/QuicConnectionContextTests.cs
Outdated
Show resolved
Hide resolved
I'm not sure. Might have been the rebase. I improved how features are resolved between streams and the connection in it. |
…ests.cs Co-authored-by: James Newton-King <[email protected]>
JamesNK
left a comment
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.
@wtgodbe I forgot that QUIC only supports client certs on Windows at the moment. Could you place an OS condition on the test?
Done |
Fixes #34756