Skip to content

Commit 8f8c286

Browse files
author
John Luo
committed
Wip
1 parent d487550 commit 8f8c286

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

.azure/pipelines/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ stages:
607607
- script: ./build.cmd -ci -nobl -noBuildRepoTasks -restore -noBuild -noBuildNative -projects src/Grpc/**/*.csproj
608608
displayName: Restore interop projects
609609
- script: ./build.cmd -ci -nobl -noBuildRepoTasks -noRestore -test -all -noBuildNative -projects eng\helix\helix.proj
610-
/p:IsRequiredCheck=true /p:IsHelixJob=true /p:BuildInteropProjects=true /p:RunTemplateTests=true
610+
/p:IsHelixDaily=true /p:IsRequiredCheck=true /p:IsHelixJob=true /p:BuildInteropProjects=true /p:RunTemplateTests=true
611611
/p:ASPNETCORE_TEST_LOG_DIR=artifacts/log
612612
displayName: Run build.cmd helix target
613613
env:

src/Servers/Kestrel/Core/src/CoreStrings.resx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,9 +566,6 @@ For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?l
566566
<data name="HTTP2NoTlsOsx" xml:space="preserve">
567567
<value>HTTP/2 over TLS is not supported on macOS due to missing ALPN support.</value>
568568
</data>
569-
<data name="HTTP2NoTlsWin7" xml:space="preserve">
570-
<value>HTTP/2 over TLS is not supported on Windows 7 due to missing ALPN support.</value>
571-
</data>
572569
<data name="Http2StreamResetByApplication" xml:space="preserve">
573570
<value>The HTTP/2 stream was reset by the application with error code {errorCode}.</value>
574571
</data>
@@ -608,6 +605,9 @@ For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?l
608605
<data name="HTTP2DefaultCiphersInsufficient" xml:space="preserve">
609606
<value>HTTP/2 over TLS is not supported on Windows versions older than Windows 10 and Windows Server 2016 due to incompatible ciphers or missing ALPN support. Falling back to HTTP/1.1 instead.</value>
610607
</data>
608+
<data name="HTTP2NoTlsWin81" xml:space="preserve">
609+
<value>HTTP/2 over TLS is not supported on Windows versions earlier than Windows 10 and Windows Server 2016 due to incompatible ciphers or missing ALPN support.</value>
610+
</data>
611611
<data name="Http2ErrorKeepAliveTimeout" xml:space="preserve">
612612
<value>Timeout while waiting for incoming HTTP/2 frames after a keep alive ping.</value>
613613
</data>

src/Servers/Kestrel/Core/src/Middleware/HttpsConnectionMiddleware.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ internal class HttpsConnectionMiddleware
3030
private readonly ILogger _logger;
3131
private readonly X509Certificate2 _serverCertificate;
3232
private readonly Func<ConnectionContext, string, X509Certificate2> _serverCertificateSelector;
33+
private const string EnableWindows81Http2 = "Microsoft.AspNetCore.Server.Kestrel.EnableWindows81Http2";
3334

3435
public HttpsConnectionMiddleware(ConnectionDelegate next, HttpsConnectionAdapterOptions options)
3536
: this(next, options, loggerFactory: NullLoggerFactory.Instance)
@@ -53,19 +54,28 @@ public HttpsConnectionMiddleware(ConnectionDelegate next, HttpsConnectionAdapter
5354
{
5455
throw new NotSupportedException(CoreStrings.HTTP2NoTlsOsx);
5556
}
56-
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Environment.OSVersion.Version < new Version(6, 2))
57+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
5758
{
58-
throw new NotSupportedException(CoreStrings.HTTP2NoTlsWin7);
59+
var enableHttp2OnWindows81 = AppContext.TryGetSwitch(EnableWindows81Http2, out var enabled) && enabled;
60+
if (Environment.OSVersion.Version < new Version(6, 3)
61+
|| (Environment.OSVersion.Version < new Version(10, 0) && !enableHttp2OnWindows81))
62+
{
63+
throw new NotSupportedException(CoreStrings.HTTP2NoTlsWin81);
64+
}
5965
}
6066
}
6167

6268
if (options.HttpProtocols == HttpProtocols.Http1AndHttp2)
6369
{
64-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
65-
&& Environment.OSVersion.Version < new Version(10, 0))
70+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
6671
{
67-
_logger.HTTP2DefaultCiphersInsufficient();
68-
options.HttpProtocols = HttpProtocols.Http1;
72+
var enableHttp2OnWindows81 = AppContext.TryGetSwitch(EnableWindows81Http2, out var enabled) && enabled;
73+
if (Environment.OSVersion.Version < new Version(6, 3)
74+
|| (Environment.OSVersion.Version < new Version(10, 0) && !enableHttp2OnWindows81))
75+
{
76+
_logger.HTTP2DefaultCiphersInsufficient();
77+
options.HttpProtocols = HttpProtocols.Http1;
78+
}
6979
}
7080
}
7181

src/Servers/Kestrel/test/FunctionalTests/Http2/HandshakeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public async Task TlsAlpnHandshakeSelectsHttp2From1and2()
112112
[ConditionalFact]
113113
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Missing SslStream ALPN support: https://github.com/dotnet/corefx/issues/30492")]
114114
[SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/10428", Queues = "Debian.8.Amd64;Debian.8.Amd64.Open")] // Debian 8 uses OpenSSL 1.0.1 which does not support HTTP/2
115-
[MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win81)]
115+
[MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10)]
116116
public async Task TlsAlpnHandshakeSelectsHttp2()
117117
{
118118
using (var server = new TestServer(context =>

0 commit comments

Comments
 (0)