-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Add TlsConnectionOptions to connection abstractions #42831
Comments
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
API review notes:
API Approved: namespace Microsoft.AspNetCore.Connections;
/// <summary>
/// Options used to configure a per connection callback for TLS configuration.
/// </summary>
public class TlsConnectionCallbackOptions
{
/// <summary>
/// The callback to invoke per connection. This property is required.
/// </summary>
public Func<TlsConnectionCallbackContext, CancellationToken, ValueTask<SslServerAuthenticationOptions>> OnConnection { get; set; } = default!;
/// <summary>
/// Optional application state to flow to the <see cref="OnConnection"/> callback.
/// </summary>
public object? OnConnectionState { get; set; }
/// <summary>
/// Gets or sets a list of ALPN protocols.
/// </summary>
public List<SslApplicationProtocol> ApplicationProtocols { get; set; } = default!;
}
/// <summary>
/// Per connection state used to determine the TLS options.
/// </summary>
public class TlsConnectionCallbackContext
{
/// <summary>
/// Information from the Client Hello message.
/// </summary>
public SslClientHelloInfo ClientHelloInfo { get; set; }
/// <summary>
/// The information that was passed when registering the callback.
/// </summary>
public object? State { get; set; }
/// <summary>
/// Information about an individual connection.
/// </summary>
public BaseConnectionContext Connection { get; set; } = default!;
} |
I finished implementing this and I found the API needs to change slightly. A QUIC connection inherits from It make sense that QUIC connection doesn't inherit from Change: public class TlsConnectionCallbackContext
{
/// <summary>
/// Information about an individual connection.
/// </summary>
- public ConnectionContext Connection { get; set; } = default!;
+ public BaseConnectionContext Connection { get; set; } = default!;
}
The existing |
Makes sense to me. I'm just going to edit the approved API to match. |
Background and Motivation
Kestrel needs to pass TLS configuration to the QUIC transport. Neither project has a dependency on the other.
Communication is done through values added to IFeatureCollection. Rather than add a loose collection of types and delegates to the feature collection, I'd rather have a strongly typed options type that has the necessary configuration.
Also, part of TLS configuration is a callback that's called for each connection to resolve
SslServerAuthenticationOptions
. If the callback takes a context object, then new values can be added in the future.Proposed API
Note: Microsoft.AspNetCore.Connections.Abstractions targets .NET Framework and .NET Standard. These types would only be present in .NET 7 it's the only target that supports
SslServerAuthenticationOptions
Usage Examples
Alternative Designs
These types are very similar to what is in Kestrel:
Risks
The text was updated successfully, but these errors were encountered: