Skip to content
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

Expose SNI hostname via a feature #34525

Closed
shirhatti opened this issue Jul 20, 2021 · 25 comments · Fixed by #48957
Closed

Expose SNI hostname via a feature #34525

shirhatti opened this issue Jul 20, 2021 · 25 comments · Fixed by #48957
Assignees
Labels
api-approved API was approved in API review, it can be implemented area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions feature-httpsys feature-iis Includes: IIS, ANCM feature-kestrel help wanted Up for grabs. We would accept a PR to help resolve this issue
Milestone

Comments

@shirhatti
Copy link
Contributor

shirhatti commented Jul 20, 2021

We currently do not expose the SNI hostname via a feature interface

// Used for event source, not part of any of the feature interfaces.
public string? HostName { get; set; }

namespace Microsoft.AspNetCore.Http.Features
{
    public interface ITlsHandshakeFeature
    {
+        string? HostName { get; }
    }
}

Given that it's already a property on the TlsConnectionFeature we can trivially expose it.

@shirhatti shirhatti added area-runtime api-suggestion Early API idea and discussion, it is NOT ready for implementation labels Jul 20, 2021
@Tratcher
Copy link
Member

Is it available on http.sys or IIS?

@shirhatti
Copy link
Contributor Author

@alanwest @cijothomas Y'all might be interested in this for open-telemetry/opentelemetry-dotnet#2159 if you wish to add the http.server_name attribute.

@shirhatti
Copy link
Contributor Author

@Tratcher Is there somewhere else I should be looking?

[StructLayout(LayoutKind.Sequential)]
internal struct HTTP_SSL_INFO
{
internal ushort ServerCertKeySize;
internal ushort ConnectionKeySize;
internal uint ServerCertIssuerSize;
internal uint ServerCertSubjectSize;
internal byte* pServerCertIssuer;
internal byte* pServerCertSubject;
internal HTTP_SSL_CLIENT_CERT_INFO* pClientCertInfo;
internal uint SslClientCertNegotiated;
}

@BrennanConroy BrennanConroy added this to the Next sprint planning milestone Jul 21, 2021
@ghost
Copy link

ghost commented Jul 21, 2021

Thanks for contacting us.

We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@BrennanConroy BrennanConroy added api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews and removed api-suggestion Early API idea and discussion, it is NOT ready for implementation labels Jul 21, 2021
@shirhatti
Copy link
Contributor Author

Microsoft.Extensions.Features targets netstandard2.0 and net461 which means I can't use a DIM 😢

<TargetFrameworks>$(DefaultNetFxTargetFramework);netstandard2.0;$(DefaultNetCoreTargetFramework)</TargetFrameworks>

@Tratcher
Copy link
Member

What are you trying to modify in Microsoft.Extensions.Features? I thought the features you needed to change were in Microsoft.AspNetCore.Http.Features?

@shirhatti
Copy link
Contributor Author

Oops. I meant

<TargetFrameworks>$(DefaultNetFxTargetFramework);netstandard2.0;netstandard2.1;$(DefaultNetCoreTargetFramework)</TargetFrameworks>

@Tratcher
Copy link
Member

Ah. I guess we'll have to put it on ITlsConnectionFeature instead.

public interface ITlsConnectionFeature

@shirhatti

This comment has been minimized.

@shirhatti shirhatti linked a pull request Jul 23, 2021 that will close this issue
@pranavkm
Copy link
Contributor

pranavkm commented Jul 26, 2021

We think it's better to add an additional feature interface to Connection.Abstractions rather than adding this to ITlsConnectionFeature:

namespace Microsoft.AspNetCore.Connection.Abstractions
{
+    public interface ITlsServerNameFeature
+    {
+        string? ServerName { get; }
+    }
}

@pranavkm pranavkm added api-approved API was approved in API review, it can be implemented and removed api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews labels Jul 26, 2021
@shirhatti
Copy link
Contributor Author

Related: #35123

@ghost
Copy link

ghost commented Aug 6, 2021

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@shirhatti
Copy link
Contributor Author

Blocked on dotnet/runtime#57105

@shirhatti shirhatti removed this from the Backlog milestone Nov 1, 2021
@shirhatti
Copy link
Contributor Author

Un-backlogging since we're no longer blocked on runtime

@ghost
Copy link

ghost commented Aug 22, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@BrennanConroy
Copy link
Member

Triage:
We can #if the new property on an existing interface to workaround netstandard not supporting default interface methods.

@halter73 halter73 added api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews and removed api-approved API was approved in API review, it can be implemented labels Feb 15, 2023
@ghost
Copy link

ghost commented Feb 15, 2023

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:

  • The PR contains changes to the reference-assembly that describe the API change. Or, you have included a snippet of reference-assembly-style code that illustrates the API change.
  • The PR describes the impact to users, both positive (useful new APIs) and negative (breaking changes).
  • Someone is assigned to "champion" this change in the meeting, and they understand the impact and design of the change.

@adityamandaleeka adityamandaleeka added this to the .NET 8 Planning milestone Feb 22, 2023
@ghost
Copy link

ghost commented Feb 22, 2023

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@halter73
Copy link
Member

namespace Microsoft.AspNetCore.Connections.Features;

public interface ITlsHandshakeFeature
{
+ #if NETCOREAPP
+     /// <summary>
+     /// Gets the host name from the "sever_name" extension of the client hello if present.
+     /// See <see href="https://www.rfc-editor.org/rfc/rfc6066#section-3">RFC 6066</see>.
+     /// </summary>
+     string? HostName => null;
+ #endif
}

Note: We already do a similar #if in ITlsHandshakeFeature for NegotiatedCipherSuite.

#if NETCOREAPP
/// <summary>
/// Gets the <see cref="TlsCipherSuite"/>.
/// </summary>
TlsCipherSuite? NegotiatedCipherSuite => null;
#endif

@halter73
Copy link
Member

API Review Notes:

  • This was already approved as separate ITlsServerNameFeature. Considering we already have NegotiatedCipherSuite on the same interface in an #if NETCOREAPP without issue, it makes sense to do it again for HostName.

API Approved!

namespace Microsoft.AspNetCore.Connections.Features;

public interface ITlsHandshakeFeature
{
+ #if NETCOREAPP
+     /// <summary>
+     /// Gets the host name from the "sever_name" extension of the client hello if present.
+     /// See <see href="https://www.rfc-editor.org/rfc/rfc6066#section-3">RFC 6066</see>.
+     /// </summary>
+     string? HostName => null;
+ #endif
}

@halter73 halter73 added api-approved API was approved in API review, it can be implemented and removed api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews labels May 25, 2023
@Tratcher Tratcher added the help wanted Up for grabs. We would accept a PR to help resolve this issue label May 26, 2023
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 2, 2023
@halter73
Copy link
Member

halter73 commented Jun 6, 2023

We decided that there was no reason to distinguish between the client sending an empty host name using SNI, the client not using SNI, and a server that doesn't support this feature in the PR. The reason the SNI host name is unavailable should not change how it's handled. This means it should be simpler to make HostName non-nullable and have the default implementation return the empty string to avoid unnecessary null checks.

Here's the updated API proposal:

namespace Microsoft.AspNetCore.Connections.Features;

public interface ITlsHandshakeFeature
{
+ #if NETCOREAPP
+     /// <summary>
+     /// Gets the host name from the "sever_name" extension of the client hello if present.
+     /// See <see href="https://www.rfc-editor.org/rfc/rfc6066#section-3">RFC 6066</see>.
+     /// </summary>
+     string HostName => string.Empty;
+ #endif
}

@halter73 halter73 added api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews and removed api-approved API was approved in API review, it can be implemented labels Jun 6, 2023
@ghost
Copy link

ghost commented Jun 6, 2023

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:

  • The PR contains changes to the reference-assembly that describe the API change. Or, you have included a snippet of reference-assembly-style code that illustrates the API change.
  • The PR describes the impact to users, both positive (useful new APIs) and negative (breaking changes).
  • Someone is assigned to "champion" this change in the meeting, and they understand the impact and design of the change.

@halter73
Copy link
Member

API Review Notes:

  • Do we need a null value to indicate the server doesn't support this?
    • Maybe, but using a null HostName is too subtle for this
    • If it's important we can add a bool.

API Approved as merged!

namespace Microsoft.AspNetCore.Connections.Features;

public interface ITlsHandshakeFeature
{
+ #if NETCOREAPP
+     /// <summary>
+     /// Gets the host name from the "sever_name" extension of the client hello if present.
+     /// See <see href="https://www.rfc-editor.org/rfc/rfc6066#section-3">RFC 6066</see>.
+     /// </summary>
+     string HostName => string.Empty;
+ #endif
}

@halter73 halter73 added api-approved API was approved in API review, it can be implemented and removed api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews labels Jun 26, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jul 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-approved API was approved in API review, it can be implemented area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions feature-httpsys feature-iis Includes: IIS, ANCM feature-kestrel help wanted Up for grabs. We would accept a PR to help resolve this issue
Projects
None yet
8 participants