Skip to content

Commit 60f23f0

Browse files
committed
PR comments & smoke tests
1 parent b431d5d commit 60f23f0

File tree

6 files changed

+33
-10
lines changed

6 files changed

+33
-10
lines changed
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
#nullable enable
2-
Microsoft.AspNetCore.Http.Features.IHttpSysRequestPropertyFeature
3-
Microsoft.AspNetCore.Http.Features.IHttpSysRequestPropertyFeature.TryGetTlsClientHello(System.Span<byte> tlsClientHelloBytesDestination, out int bytesReturned) -> bool
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
namespace Microsoft.AspNetCore.Http.Features;
4+
namespace Microsoft.AspNetCore.Server.HttpSys;
55

66
/// <summary>
77
/// Provides API to read HTTP_REQUEST_PROPERTY value from the HTTP.SYS request.
@@ -12,23 +12,25 @@ public interface IHttpSysRequestPropertyFeature
1212
/// <summary>
1313
/// Reads the TLS client hello from HTTP.SYS
1414
/// </summary>
15-
/// <param name="tlsClientHelloBytesDestination">where raw bytes of tls client hello message will be written</param>
15+
/// <param name="tlsClientHelloBytesDestination">Where the raw bytes of the TLS Client Hello message will be written.</param>
1616
/// <param name="bytesReturned">
1717
/// Returns the number of bytes written to <paramref name="tlsClientHelloBytesDestination"/>.
18-
/// Or can return the size of buffer needed if <paramref name="tlsClientHelloBytesDestination"/> wasn't large enough.
18+
/// Or can return the size of the buffer needed if <paramref name="tlsClientHelloBytesDestination"/> wasn't large enough.
1919
/// </param>
2020
/// <remarks>
2121
/// Works only if <c>HTTP_SERVICE_CONFIG_SSL_FLAG_ENABLE_CACHE_CLIENT_HELLO</c> flag is set on http.sys service configuration.
2222
/// See <see href="https://learn.microsoft.com/windows/win32/api/http/nf-http-httpsetserviceconfiguration"/>
2323
/// and <see href="https://learn.microsoft.com/windows/win32/api/http/ne-http-http_service_config_id"/>
2424
/// <br/><br/>
25-
/// If you don't want to guess required <paramref name="tlsClientHelloBytesDestination"/> size before first invocation,
26-
/// you should call first with <paramref name="tlsClientHelloBytesDestination"/> set to empty size, so that you can retrieve through <paramref name="bytesReturned"/> the buffer size you need,
27-
/// then allocate that amount of memory, then retry the query.
25+
/// If you don't want to guess the required <paramref name="tlsClientHelloBytesDestination"/> size before first invocation,
26+
/// you should first call with <paramref name="tlsClientHelloBytesDestination"/> set to empty size, so that you can retrieve the required buffer size from <paramref name="bytesReturned"/>,
27+
/// then allocate that amount of memory and retry the query.
2828
/// </remarks>
2929
/// <returns>
3030
/// True, if fetching TLS client hello was successful, false if <paramref name="tlsClientHelloBytesDestination"/> size is not large enough.
3131
/// If non-successful for other reason throws an exception.
3232
/// </returns>
33+
/// <exception cref="HttpSysException">Any HttpSys error except for ERROR_INSUFFICIENT_BUFFER or ERROR_MORE_DATA.</exception>
34+
/// <exception cref="InvalidOperationException">If HttpSys does not support querying the TLS Client Hello.</exception>
3335
bool TryGetTlsClientHello(Span<byte> tlsClientHelloBytesDestination, out int bytesReturned);
3436
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#nullable enable
22
Microsoft.AspNetCore.Server.HttpSys.HttpSysOptions.RequestQueueSecurityDescriptor.get -> System.Security.AccessControl.GenericSecurityDescriptor?
33
Microsoft.AspNetCore.Server.HttpSys.HttpSysOptions.RequestQueueSecurityDescriptor.set -> void
4+
Microsoft.AspNetCore.Server.HttpSys.IHttpSysRequestPropertyFeature
5+
Microsoft.AspNetCore.Server.HttpSys.IHttpSysRequestPropertyFeature.TryGetTlsClientHello(System.Span<byte> tlsClientHelloBytesDestination, out int bytesReturned) -> bool

src/Servers/HttpSys/src/RequestProcessing/RequestContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public RequestContext(HttpSysListener server, uint? bufferSize, ulong requestId)
3333

3434
public Request Request { get; private set; } = default!;
3535

36-
public Response Response { get; private set; } = default!;
36+
public Response Response { get; private set; } = default!;
3737

3838
public WindowsPrincipal User => Request.User;
3939

src/Servers/HttpSys/test/FunctionalTests/HttpsTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,27 @@ public async Task Https_ITlsHandshakeFeature_MatchesIHttpSysExtensionInfoFeature
239239
}
240240
}
241241

242+
[ConditionalFact]
243+
[MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10_20H2)]
244+
public void Https_SetsIHttpSysRequestPropertyFeature()
245+
{
246+
using (Utilities.CreateDynamicHttpsServer(out var address, async httpContext =>
247+
{
248+
try
249+
{
250+
var requestPropertyFeature = httpContext.Features.Get<IHttpSysRequestPropertyFeature>();
251+
Assert.NotNull(requestPropertyFeature);
252+
}
253+
catch (Exception ex)
254+
{
255+
await httpContext.Response.WriteAsync(ex.ToString());
256+
}
257+
}, LoggerFactory))
258+
{
259+
// nothing
260+
}
261+
}
262+
242263
[ConditionalFact]
243264
[MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10_20H2)]
244265
public async Task Https_SetsIHttpSysRequestTimingFeature()

src/Servers/Kestrel/Core/src/ListenOptionsHttpsExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public static ListenOptions UseHttps(this ListenOptions listenOptions, Action<Ht
188188
/// <see cref="KestrelServerOptions.ConfigureHttpsDefaults(Action{HttpsConnectionAdapterOptions})"/>.
189189
/// </summary>
190190
/// <param name="listenOptions">The <see cref="ListenOptions"/> to configure.</param>
191-
/// <param name="httpsOptions">Options to configure HTTPS.</param>
191+
/// <param name="httpsOptions">Options to configure HTTPS.</param>
192192
/// <returns>The <see cref="ListenOptions"/>.</returns>
193193
public static ListenOptions UseHttps(this ListenOptions listenOptions, HttpsConnectionAdapterOptions httpsOptions)
194194
{

0 commit comments

Comments
 (0)