Skip to content

Commit bb92c60

Browse files
author
John Luo
authored
Fix Windows 7/8 Kestrel tests (#23069)
1 parent 6fe00bf commit bb92c60

File tree

5 files changed

+23
-21
lines changed

5 files changed

+23
-21
lines changed

src/Servers/Kestrel/test/InMemory.FunctionalTests/HttpsConnectionMiddlewareTests.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void ConfigureListenOptions(ListenOptions listenOptions)
142142
using (var connection = server.CreateConnection())
143143
{
144144
var stream = OpenSslStream(connection.Stream);
145-
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
145+
await stream.AuthenticateAsClientAsync("localhost");
146146
Assert.True(stream.RemoteCertificate.Equals(_x509Certificate2));
147147
}
148148
}
@@ -172,7 +172,7 @@ void ConfigureListenOptions(ListenOptions listenOptions)
172172
using (var connection = server.CreateConnection())
173173
{
174174
var stream = OpenSslStream(connection.Stream);
175-
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
175+
await stream.AuthenticateAsClientAsync("localhost");
176176
Assert.True(stream.RemoteCertificate.Equals(_x509Certificate2));
177177
Assert.Equal(1, selectorCalled);
178178
}
@@ -207,14 +207,14 @@ void ConfigureListenOptions(ListenOptions listenOptions)
207207
using (var connection = server.CreateConnection())
208208
{
209209
var stream = OpenSslStream(connection.Stream);
210-
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
210+
await stream.AuthenticateAsClientAsync("localhost");
211211
Assert.True(stream.RemoteCertificate.Equals(_x509Certificate2));
212212
Assert.Equal(1, selectorCalled);
213213
}
214214
using (var connection = server.CreateConnection())
215215
{
216216
var stream = OpenSslStream(connection.Stream);
217-
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
217+
await stream.AuthenticateAsClientAsync("localhost");
218218
Assert.True(stream.RemoteCertificate.Equals(_x509Certificate2NoExt));
219219
Assert.Equal(2, selectorCalled);
220220
}
@@ -274,7 +274,7 @@ void ConfigureListenOptions(ListenOptions listenOptions)
274274
using (var connection = server.CreateConnection())
275275
{
276276
var stream = OpenSslStream(connection.Stream);
277-
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
277+
await stream.AuthenticateAsClientAsync("localhost");
278278
Assert.True(stream.RemoteCertificate.Equals(_x509Certificate2));
279279
Assert.Equal(1, selectorCalled);
280280
}
@@ -340,7 +340,7 @@ void ConfigureListenOptions(ListenOptions listenOptions)
340340
// HttpClient might not send the certificate because it is invalid or it doesn't match any
341341
// of the certificate authorities sent by the server in the SSL handshake.
342342
var stream = OpenSslStreamWithCert(connection.Stream);
343-
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
343+
await stream.AuthenticateAsClientAsync("localhost");
344344
await AssertConnectionResult(stream, true);
345345
}
346346
}
@@ -417,7 +417,7 @@ void ConfigureListenOptions(ListenOptions listenOptions)
417417
using (var connection = server.CreateConnection())
418418
{
419419
var stream = OpenSslStreamWithCert(connection.Stream);
420-
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
420+
await stream.AuthenticateAsClientAsync("localhost");
421421
await AssertConnectionResult(stream, true);
422422
Assert.True(clientCertificateValidationCalled);
423423
}
@@ -444,7 +444,7 @@ void ConfigureListenOptions(ListenOptions listenOptions)
444444
using (var connection = server.CreateConnection())
445445
{
446446
var stream = OpenSslStreamWithCert(connection.Stream);
447-
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
447+
await stream.AuthenticateAsClientAsync("localhost");
448448
await AssertConnectionResult(stream, false);
449449
}
450450
}
@@ -469,7 +469,7 @@ void ConfigureListenOptions(ListenOptions listenOptions)
469469
using (var connection = server.CreateConnection())
470470
{
471471
var stream = OpenSslStreamWithCert(connection.Stream);
472-
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
472+
await stream.AuthenticateAsClientAsync("localhost");
473473
await AssertConnectionResult(stream, false);
474474
}
475475
}
@@ -494,7 +494,7 @@ void ConfigureListenOptions(ListenOptions listenOptions)
494494
using (var connection = server.CreateConnection())
495495
{
496496
var stream = OpenSslStreamWithCert(connection.Stream);
497-
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
497+
await stream.AuthenticateAsClientAsync("localhost");
498498
await AssertConnectionResult(stream, true);
499499
}
500500
}
@@ -528,7 +528,7 @@ void ConfigureListenOptions(ListenOptions listenOptions)
528528
using (var connection = server.CreateConnection())
529529
{
530530
var stream = OpenSslStreamWithCert(connection.Stream);
531-
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
531+
await stream.AuthenticateAsClientAsync("localhost");
532532
await AssertConnectionResult(stream, true);
533533
}
534534
}
@@ -609,7 +609,7 @@ void ConfigureListenOptions(ListenOptions listenOptions)
609609
var sslOptions = new SslClientAuthenticationOptions
610610
{
611611
TargetHost = "localhost",
612-
EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11,
612+
EnabledSslProtocols = SslProtocols.None,
613613
ApplicationProtocols = new List<SslApplicationProtocol> { SslApplicationProtocol.Http11, SslApplicationProtocol.Http2 },
614614
};
615615

src/Servers/Kestrel/test/InMemory.FunctionalTests/HttpsTests.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ public void ConfigureCertSelectorNeverLoadsDefaultCert()
115115
Assert.Null(serverOptions.DefaultCertificate);
116116
}
117117

118-
[Fact]
118+
[ConditionalFact]
119+
[MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10)] // Investigation: https://github.com/dotnet/aspnetcore/issues/22917
119120
public async Task EmptyRequestLoggedAsDebug()
120121
{
121122
var loggerProvider = new HandshakeErrorLoggerProvider();
@@ -142,7 +143,8 @@ public async Task EmptyRequestLoggedAsDebug()
142143
userMessage: string.Join(Environment.NewLine, loggerProvider.ErrorLogger.ErrorMessages));
143144
}
144145

145-
[Fact]
146+
[ConditionalFact]
147+
[MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10)] // Investigation: https://github.com/dotnet/aspnetcore/issues/22917
146148
public async Task ClientHandshakeFailureLoggedAsDebug()
147149
{
148150
var loggerProvider = new HandshakeErrorLoggerProvider();
@@ -415,7 +417,7 @@ public async Task OnAuthenticate_SeesOtherSettings()
415417
using (var sslStream = new SslStream(connection.Stream, true, (sender, certificate, chain, errors) => true))
416418
{
417419
await sslStream.AuthenticateAsClientAsync("127.0.0.1", clientCertificates: null,
418-
enabledSslProtocols: SslProtocols.Tls11 | SslProtocols.Tls12,
420+
enabledSslProtocols: SslProtocols.None,
419421
checkCertificateRevocation: false);
420422
}
421423
}
@@ -454,7 +456,7 @@ public async Task OnAuthenticate_CanSetSettings()
454456
using (var sslStream = new SslStream(connection.Stream, true, (sender, certificate, chain, errors) => true))
455457
{
456458
await sslStream.AuthenticateAsClientAsync("127.0.0.1", clientCertificates: null,
457-
enabledSslProtocols: SslProtocols.Tls11 | SslProtocols.Tls12,
459+
enabledSslProtocols: SslProtocols.None,
458460
checkCertificateRevocation: false);
459461
}
460462
}

src/Servers/Kestrel/test/Interop.FunctionalTests/H2SpecTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static TheoryData<H2SpecTestCase> H2SpecTestCases
5555
var dataset = new TheoryData<H2SpecTestCase>();
5656
var toSkip = new string[] { /*"http2/5.1/8"*/ };
5757

58-
var supportsAlpn = Utilities.CurrentPlatformSupportsAlpn();
58+
var supportsAlpn = Utilities.CurrentPlatformSupportsHTTP2OverTls();
5959

6060
foreach (var testcase in H2SpecCommands.EnumerateTestCases())
6161
{

src/Servers/Kestrel/test/Interop.FunctionalTests/HttpClientHttp2InteropTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static IEnumerable<object[]> SupportedSchemes
4242
new[] { "http" }
4343
};
4444

45-
if (Utilities.CurrentPlatformSupportsAlpn())
45+
if (Utilities.CurrentPlatformSupportsHTTP2OverTls())
4646
{
4747
list.Add(new[] { "https" });
4848
}

src/Servers/Kestrel/test/Interop.FunctionalTests/Utilities.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ namespace Interop.FunctionalTests
77
{
88
internal static class Utilities
99
{
10-
internal static bool CurrentPlatformSupportsAlpn()
10+
internal static bool CurrentPlatformSupportsHTTP2OverTls()
1111
{
12-
return // "Missing Windows ALPN support: https://en.wikipedia.org/wiki/Application-Layer_Protocol_Negotiation#Support"
13-
new MinimumOSVersionAttribute(OperatingSystems.Windows, WindowsVersions.Win81).IsMet
12+
return // "Missing Windows ALPN support: https://en.wikipedia.org/wiki/Application-Layer_Protocol_Negotiation#Support" or missing compatible ciphers (Win8.1)
13+
new MinimumOSVersionAttribute(OperatingSystems.Windows, WindowsVersions.Win10).IsMet
1414
// "Missing SslStream ALPN support: https://github.com/dotnet/corefx/issues/30492"
1515
&& new OSSkipConditionAttribute(OperatingSystems.MacOSX).IsMet
1616
// Debian 8 uses OpenSSL 1.0.1 which does not support ALPN

0 commit comments

Comments
 (0)