diff --git a/src/Servers/HttpSys/src/StandardFeatureCollection.cs b/src/Servers/HttpSys/src/StandardFeatureCollection.cs index 69158b62d1..88c1f7bff9 100644 --- a/src/Servers/HttpSys/src/StandardFeatureCollection.cs +++ b/src/Servers/HttpSys/src/StandardFeatureCollection.cs @@ -20,8 +20,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys { typeof(IHttpResponseFeature), _identityFunc }, { typeof(IHttpSendFileFeature), _identityFunc }, { typeof(ITlsConnectionFeature), ctx => ctx.GetTlsConnectionFeature() }, - { typeof(ITlsHandshakeFeature), ctx => ctx.GetTlsHandshakeFeature() }, - // { typeof(ITlsTokenBindingFeature), ctx => ctx.GetTlsTokenBindingFeature() }, TODO: https://github.com/aspnet/HttpSysServer/issues/231 { typeof(IHttpBufferingFeature), _identityFunc }, { typeof(IHttpRequestLifetimeFeature), _identityFunc }, { typeof(IHttpAuthenticationFeature), _identityFunc }, @@ -41,6 +39,8 @@ namespace Microsoft.AspNetCore.Server.HttpSys // SignalR uses the presence of the feature to detect feature support. // https://github.com/aspnet/HttpSysServer/issues/427 _featureFuncLookup[typeof(IHttpUpgradeFeature)] = _identityFunc; + // Win8+ + _featureFuncLookup[typeof(ITlsHandshakeFeature)] = ctx => ctx.GetTlsHandshakeFeature(); } } diff --git a/src/Servers/HttpSys/test/FunctionalTests/HttpsTests.cs b/src/Servers/HttpSys/test/FunctionalTests/HttpsTests.cs index d3e4fa54ce..7b99af24a4 100644 --- a/src/Servers/HttpSys/test/FunctionalTests/HttpsTests.cs +++ b/src/Servers/HttpSys/test/FunctionalTests/HttpsTests.cs @@ -102,9 +102,32 @@ namespace Microsoft.AspNetCore.Server.HttpSys } [ConditionalFact] + [OSDontSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, WindowsVersions.Win2008R2)] + public async Task Https_SkipsITlsHandshakeFeatureOnWin7() + { + using (Utilities.CreateDynamicHttpsServer(out var address, async httpContext => + { + try + { + var tlsFeature = httpContext.Features.Get(); + Assert.Null(tlsFeature); + } + catch (Exception ex) + { + await httpContext.Response.WriteAsync(ex.ToString()); + } + })) + { + string response = await SendRequestAsync(address); + Assert.Equal(string.Empty, response); + } + } + + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, WindowsVersions.Win2008R2)] public async Task Https_SetsITlsHandshakeFeature() { - using (Utilities.CreateDynamicHttpsServer(out var address, httpContext => + using (Utilities.CreateDynamicHttpsServer(out var address, async httpContext => { try { @@ -121,9 +144,8 @@ namespace Microsoft.AspNetCore.Server.HttpSys } catch (Exception ex) { - return httpContext.Response.WriteAsync(ex.ToString()); + await httpContext.Response.WriteAsync(ex.ToString()); } - return Task.FromResult(0); })) { string response = await SendRequestAsync(address);