-
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
[API Proposal]: Add TargetHostName to QuicConnection #80508
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsBackground and motivationConsider the following code:
On HTTP 1 and 2 connections, that all works perfectly fine. With .NET 7 and HTTP 3, I noticed HandlePinningPolicy was throwing an exception:
The problem is obvious, so I decided to add a check for when the As a result, pinning HTTP 3 connections seems impossible. Any temporary workaround would be appreciated.🙂 API Proposalnamespace System.Net.Quic;
public sealed partial class QuicConnection : IAsyncDisposable
{
+ public string TargetHostName { ... }
} API Usageif (PinList != null && PinList.TryGetValue(sender is QuicConnection qc ? qc.TargetHostName : ((SslStream)sender).TargetHostName, out var pin)) return new Span<byte>(pin).SequenceEqual(SHA256.HashData(certificate.GetPublicKey())); Alternative DesignsNo response RisksNone
|
This would make sense to me. It seems like we already have |
@wfurt Thank you for the tip. I came up with this, which is an acceptable workaround for now. Hopefully you will consider my proposal so this can be cleaned up later.🙂
|
For the record, here is #27619 original ask for SslStream. |
Tagging subscribers to this area: @dotnet/ncl Issue DetailsBackground and motivationConsider the following code:
On HTTP 1 and 2 connections, that all works perfectly fine. With .NET 7 and HTTP 3, I noticed HandlePinningPolicy was throwing an exception:
The problem is obvious, so I decided to add a check for when the As a result, pinning HTTP 3 connections seems impossible. Any temporary workaround would be appreciated.🙂 API Proposalnamespace System.Net.Quic;
public sealed partial class QuicConnection : IAsyncDisposable
{
+ public string TargetHostName { ... }
} API Usageif (PinList != null && PinList.TryGetValue(sender is QuicConnection qc ? qc.TargetHostName : ((SslStream)sender).TargetHostName, out var pin)) return new Span<byte>(pin).SequenceEqual(SHA256.HashData(certificate.GetPublicKey())); Alternative DesignsNo response RisksNone
|
Triage: this seems fairly easy so we could do it in 8.0. And we have precedent in |
Related issue: #70184 |
Related: We might want to not pass IP literals as ServerName to
|
Looks good as proposed (assuming "..." was "get;") namespace System.Net.Quic;
public sealed partial class QuicConnection : IAsyncDisposable
{
public string TargetHostName { get; }
} |
* Add TargetHostName to QuicConnection Fixes #80508 * Make TargetHostName not nullable * Fix build * Fix build of tests * Fix failing tests * Code review feedback * Use unencoded hostname in user-facing properties/params * Fix failing tests * Revert unwanted changes * Add test for IDN cert validation * Fix test again * Fix trailing dot in hostname
Background and motivation
Consider the following code:
On HTTP 1 and 2 connections, that all works perfectly fine. With .NET 7 and HTTP 3, I noticed HandlePinningPolicy was throwing an exception:
Unable to cast object of type 'System.Net.Quic.QuicConnection' to type 'System.Net.Security.SslStream'.
The problem is obvious, so I decided to add a check for when the
sender
isQuicConnection
. Just one problem though..QuicConnection
doesn't provide the host name of the connection, and I do not see any way to get it:As a result, pinning HTTP 3 connections seems impossible.
Any temporary workaround would be appreciated.🙂
API Proposal
namespace System.Net.Quic; public sealed partial class QuicConnection : IAsyncDisposable { + public string TargetHostName { ... } }
API Usage
Alternative Designs
No response
Risks
None
The text was updated successfully, but these errors were encountered: