Fail on startup for Http/2 HTTPS on Win7 (#12053)
This commit is contained in:
parent
a279af52d2
commit
70588c741b
|
|
@ -1,6 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Templates.Test.Helpers;
|
using Templates.Test.Helpers;
|
||||||
|
|
@ -46,6 +47,12 @@ namespace Templates.Test
|
||||||
Assert.Contains("System.NotSupportedException: HTTP/2 over TLS is not supported on OSX due to missing ALPN support.",
|
Assert.Contains("System.NotSupportedException: HTTP/2 over TLS is not supported on OSX due to missing ALPN support.",
|
||||||
ErrorMessages.GetFailedProcessMessageOrEmpty("Run built service", Project, serverProcess.Process));
|
ErrorMessages.GetFailedProcessMessageOrEmpty("Run built service", Project, serverProcess.Process));
|
||||||
}
|
}
|
||||||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Environment.OSVersion.Version < new Version(6, 2))
|
||||||
|
{
|
||||||
|
Assert.True(serverProcess.Process.HasExited, "built");
|
||||||
|
Assert.Contains("System.NotSupportedException: HTTP/2 over TLS is not supported on Windows 7 due to missing ALPN support.",
|
||||||
|
ErrorMessages.GetFailedProcessMessageOrEmpty("Run built service", Project, serverProcess.Process));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Assert.False(
|
Assert.False(
|
||||||
|
|
@ -64,6 +71,12 @@ namespace Templates.Test
|
||||||
Assert.Contains("System.NotSupportedException: HTTP/2 over TLS is not supported on OSX due to missing ALPN support.",
|
Assert.Contains("System.NotSupportedException: HTTP/2 over TLS is not supported on OSX due to missing ALPN support.",
|
||||||
ErrorMessages.GetFailedProcessMessageOrEmpty("Run published service", Project, aspNetProcess.Process));
|
ErrorMessages.GetFailedProcessMessageOrEmpty("Run published service", Project, aspNetProcess.Process));
|
||||||
}
|
}
|
||||||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Environment.OSVersion.Version < new Version(6, 2))
|
||||||
|
{
|
||||||
|
Assert.True(aspNetProcess.Process.HasExited, "published");
|
||||||
|
Assert.Contains("System.NotSupportedException: HTTP/2 over TLS is not supported on Windows 7 due to missing ALPN support.",
|
||||||
|
ErrorMessages.GetFailedProcessMessageOrEmpty("Run published service", Project, aspNetProcess.Process));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Assert.False(
|
Assert.False(
|
||||||
|
|
|
||||||
|
|
@ -608,6 +608,9 @@ For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?l
|
||||||
<data name="HTTP2NoTlsOsx" xml:space="preserve">
|
<data name="HTTP2NoTlsOsx" xml:space="preserve">
|
||||||
<value>HTTP/2 over TLS is not supported on OSX due to missing ALPN support.</value>
|
<value>HTTP/2 over TLS is not supported on OSX due to missing ALPN support.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="HTTP2NoTlsWin7" xml:space="preserve">
|
||||||
|
<value>HTTP/2 over TLS is not supported on Windows 7 due to missing ALPN support.</value>
|
||||||
|
</data>
|
||||||
<data name="Http2StreamResetByApplication" xml:space="preserve">
|
<data name="Http2StreamResetByApplication" xml:space="preserve">
|
||||||
<value>The HTTP/2 stream was reset by the application with error code {errorCode}.</value>
|
<value>The HTTP/2 stream was reset by the application with error code {errorCode}.</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,16 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Https.Internal
|
||||||
}
|
}
|
||||||
|
|
||||||
// This configuration will always fail per-request, preemptively fail it here. See HttpConnection.SelectProtocol().
|
// This configuration will always fail per-request, preemptively fail it here. See HttpConnection.SelectProtocol().
|
||||||
if (options.HttpProtocols == HttpProtocols.Http2 && RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
if (options.HttpProtocols == HttpProtocols.Http2)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException(CoreStrings.HTTP2NoTlsOsx);
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||||
|
{
|
||||||
|
throw new NotSupportedException(CoreStrings.HTTP2NoTlsOsx);
|
||||||
|
}
|
||||||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Environment.OSVersion.Version < new Version(6, 2))
|
||||||
|
{
|
||||||
|
throw new NotSupportedException(CoreStrings.HTTP2NoTlsWin7);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_next = next;
|
_next = next;
|
||||||
|
|
|
||||||
|
|
@ -320,8 +320,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Tests
|
||||||
[InlineData("http1", HttpProtocols.Http1)]
|
[InlineData("http1", HttpProtocols.Http1)]
|
||||||
// [InlineData("http2", HttpProtocols.Http2)] // Not supported due to missing ALPN support. https://github.com/dotnet/corefx/issues/33016
|
// [InlineData("http2", HttpProtocols.Http2)] // Not supported due to missing ALPN support. https://github.com/dotnet/corefx/issues/33016
|
||||||
[InlineData("http1AndHttp2", HttpProtocols.Http1AndHttp2)] // Gracefully falls back to HTTP/1
|
[InlineData("http1AndHttp2", HttpProtocols.Http1AndHttp2)] // Gracefully falls back to HTTP/1
|
||||||
[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.Windows)]
|
[OSSkipCondition(OperatingSystems.Linux)]
|
||||||
public void DefaultConfigSectionCanSetProtocols_Mac(string input, HttpProtocols expected)
|
[OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win10, WindowsVersions.Win8, WindowsVersions.Win81)]
|
||||||
|
public void DefaultConfigSectionCanSetProtocols_MacAndWin7(string input, HttpProtocols expected)
|
||||||
=> DefaultConfigSectionCanSetProtocols(input, expected);
|
=> DefaultConfigSectionCanSetProtocols(input, expected);
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
|
|
@ -329,7 +330,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Tests
|
||||||
[InlineData("http2", HttpProtocols.Http2)]
|
[InlineData("http2", HttpProtocols.Http2)]
|
||||||
[InlineData("http1AndHttp2", HttpProtocols.Http1AndHttp2)]
|
[InlineData("http1AndHttp2", HttpProtocols.Http1AndHttp2)]
|
||||||
[OSSkipCondition(OperatingSystems.MacOSX)]
|
[OSSkipCondition(OperatingSystems.MacOSX)]
|
||||||
public void DefaultConfigSectionCanSetProtocols_NonMac(string input, HttpProtocols expected)
|
[OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7)]
|
||||||
|
public void DefaultConfigSectionCanSetProtocols_NonMacAndWin7(string input, HttpProtocols expected)
|
||||||
=> DefaultConfigSectionCanSetProtocols(input, expected);
|
=> DefaultConfigSectionCanSetProtocols(input, expected);
|
||||||
|
|
||||||
private void DefaultConfigSectionCanSetProtocols(string input, HttpProtocols expected)
|
private void DefaultConfigSectionCanSetProtocols(string input, HttpProtocols expected)
|
||||||
|
|
@ -387,8 +389,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Tests
|
||||||
[InlineData("http1", HttpProtocols.Http1)]
|
[InlineData("http1", HttpProtocols.Http1)]
|
||||||
// [InlineData("http2", HttpProtocols.Http2)] // Not supported due to missing ALPN support. https://github.com/dotnet/corefx/issues/33016
|
// [InlineData("http2", HttpProtocols.Http2)] // Not supported due to missing ALPN support. https://github.com/dotnet/corefx/issues/33016
|
||||||
[InlineData("http1AndHttp2", HttpProtocols.Http1AndHttp2)] // Gracefully falls back to HTTP/1
|
[InlineData("http1AndHttp2", HttpProtocols.Http1AndHttp2)] // Gracefully falls back to HTTP/1
|
||||||
[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.Windows)]
|
[OSSkipCondition(OperatingSystems.Linux)]
|
||||||
public void EndpointConfigSectionCanSetProtocols_Mac(string input, HttpProtocols expected) =>
|
[OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win10, WindowsVersions.Win8, WindowsVersions.Win81)]
|
||||||
|
public void EndpointConfigSectionCanSetProtocols_MacAndWin7(string input, HttpProtocols expected) =>
|
||||||
EndpointConfigSectionCanSetProtocols(input, expected);
|
EndpointConfigSectionCanSetProtocols(input, expected);
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
|
|
@ -396,7 +399,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Tests
|
||||||
[InlineData("http2", HttpProtocols.Http2)]
|
[InlineData("http2", HttpProtocols.Http2)]
|
||||||
[InlineData("http1AndHttp2", HttpProtocols.Http1AndHttp2)]
|
[InlineData("http1AndHttp2", HttpProtocols.Http1AndHttp2)]
|
||||||
[OSSkipCondition(OperatingSystems.MacOSX)]
|
[OSSkipCondition(OperatingSystems.MacOSX)]
|
||||||
public void EndpointConfigSectionCanSetProtocols_NonMac(string input, HttpProtocols expected) =>
|
[OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7)]
|
||||||
|
public void EndpointConfigSectionCanSetProtocols_NonMacAndWin7(string input, HttpProtocols expected) =>
|
||||||
EndpointConfigSectionCanSetProtocols(input, expected);
|
EndpointConfigSectionCanSetProtocols(input, expected);
|
||||||
|
|
||||||
private void EndpointConfigSectionCanSetProtocols(string input, HttpProtocols expected)
|
private void EndpointConfigSectionCanSetProtocols(string input, HttpProtocols expected)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ using System;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Security;
|
using System.Net.Security;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
|
@ -57,6 +56,29 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.Http2
|
||||||
Assert.Equal("HTTP/2 over TLS is not supported on OSX due to missing ALPN support.", ex.Message);
|
Assert.Equal("HTTP/2 over TLS is not supported on OSX due to missing ALPN support.", ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[ConditionalFact]
|
||||||
|
[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)]
|
||||||
|
[OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win10, WindowsVersions.Win8, WindowsVersions.Win81)]
|
||||||
|
// Win7 SslStream is missing ALPN support.
|
||||||
|
public void TlsAndHttp2NotSupportedOnWin7()
|
||||||
|
{
|
||||||
|
var ex = Assert.Throws<NotSupportedException>(() => new TestServer(context =>
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}, new TestServiceContext(LoggerFactory),
|
||||||
|
kestrelOptions =>
|
||||||
|
{
|
||||||
|
kestrelOptions.Listen(IPAddress.Loopback, 0, listenOptions =>
|
||||||
|
{
|
||||||
|
listenOptions.Protocols = HttpProtocols.Http2;
|
||||||
|
listenOptions.UseHttps(_x509Certificate2);
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
|
Assert.Equal("HTTP/2 over TLS is not supported on Windows 7 due to missing ALPN support.", ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
[ConditionalFact]
|
[ConditionalFact]
|
||||||
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Missing SslStream ALPN support: https://github.com/dotnet/corefx/issues/30492")]
|
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Missing SslStream ALPN support: https://github.com/dotnet/corefx/issues/30492")]
|
||||||
[SkipOnHelix("https://github.com/aspnet/AspNetCore/issues/10428", Queues = "Debian.8.Amd64.Open")] // Debian 8 uses OpenSSL 1.0.1 which does not support HTTP/2
|
[SkipOnHelix("https://github.com/aspnet/AspNetCore/issues/10428", Queues = "Debian.8.Amd64.Open")] // Debian 8 uses OpenSSL 1.0.1 which does not support HTTP/2
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue