diff --git a/samples/SampleApp/Startup.cs b/samples/SampleApp/Startup.cs index 61bd9a3aa1..7ececbb741 100644 --- a/samples/SampleApp/Startup.cs +++ b/samples/SampleApp/Startup.cs @@ -2,18 +2,15 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.IO; +using System.Security.Cryptography.X509Certificates; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Features; using Microsoft.AspNet.Server.Kestrel; -using Microsoft.Extensions.PlatformAbstractions; -using Microsoft.Extensions.Logging; - -#if DNX451 -using System.IO; -using System.Security.Cryptography.X509Certificates; using Microsoft.AspNet.Server.Kestrel.Https; -#endif +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.PlatformAbstractions; namespace SampleApp { @@ -29,7 +26,6 @@ namespace SampleApp loggerFactory.AddConsole(LogLevel.Debug); -#if DNX451 var testCertPath = Path.Combine( env.ApplicationBasePath, @"../../test/Microsoft.AspNet.Server.KestrelTests/TestResources/testCert.pfx"); @@ -42,7 +38,6 @@ namespace SampleApp { Console.WriteLine("Could not find certificate at '{0}'. HTTPS is not enabled.", testCertPath); } -#endif app.Run(async context => { diff --git a/samples/SampleApp/project.json b/samples/SampleApp/project.json index fb159ea155..751414ca5d 100644 --- a/samples/SampleApp/project.json +++ b/samples/SampleApp/project.json @@ -2,13 +2,11 @@ "version": "1.0.0-*", "dependencies": { "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", + "Microsoft.AspNet.Server.Kestrel.Https": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, "frameworks": { "dnx451": { - "dependencies": { - "Microsoft.AspNet.Server.Kestrel.Https": "1.0.0-*" - } }, "dnxcore50": { "dependencies": { diff --git a/src/Microsoft.AspNet.Server.Kestrel.Https/project.json b/src/Microsoft.AspNet.Server.Kestrel.Https/project.json index 3d47f866e2..5067c4bf98 100644 --- a/src/Microsoft.AspNet.Server.Kestrel.Https/project.json +++ b/src/Microsoft.AspNet.Server.Kestrel.Https/project.json @@ -12,6 +12,11 @@ "Microsoft.AspNet.Server.Kestrel": "1.0.0-*" }, "frameworks": { - "net451": { } + "net451": { }, + "dotnet5.4": { + "dependencies": { + "System.Net.Security": "4.0.0-beta-*" + } + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNet.Server.KestrelTests/HttpsConnectionFilterTests.cs b/test/Microsoft.AspNet.Server.KestrelTests/HttpsConnectionFilterTests.cs index b4e5dbe443..cf68bd89b1 100644 --- a/test/Microsoft.AspNet.Server.KestrelTests/HttpsConnectionFilterTests.cs +++ b/test/Microsoft.AspNet.Server.KestrelTests/HttpsConnectionFilterTests.cs @@ -1,7 +1,7 @@ // 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. -#if DNX451 +using System; using System.Collections.Generic; using System.Net; using System.Net.Http; @@ -47,7 +47,13 @@ namespace Microsoft.AspNet.Server.KestrelTests try { +#if DNX451 + var handler = new HttpClientHandler(); ServicePointManager.ServerCertificateValidationCallback += validationCallback; +#else + var handler = new WinHttpHandler(); + handler.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; +#endif var sereverAddress = "https://localhost:54321/"; var serviceContext = new TestServiceContext() @@ -59,7 +65,7 @@ namespace Microsoft.AspNet.Server.KestrelTests using (var server = new TestServer(App, serviceContext, sereverAddress)) { - using (var client = new HttpClient()) + using (var client = new HttpClient(handler)) { var result = await client.PostAsync(sereverAddress, new FormUrlEncodedContent(new[] { new KeyValuePair("content", "Hello World?") @@ -71,9 +77,10 @@ namespace Microsoft.AspNet.Server.KestrelTests } finally { +#if DNX451 ServicePointManager.ServerCertificateValidationCallback -= validationCallback; +#endif } } } } -#endif diff --git a/test/Microsoft.AspNet.Server.KestrelTests/project.json b/test/Microsoft.AspNet.Server.KestrelTests/project.json index 61719edb2a..730c809d15 100644 --- a/test/Microsoft.AspNet.Server.KestrelTests/project.json +++ b/test/Microsoft.AspNet.Server.KestrelTests/project.json @@ -3,19 +3,17 @@ "dependencies": { "xunit.runner.aspnet": "2.0.0-aspnet-*", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", - "Microsoft.AspNet.Testing": "1.0.0-*" + "Microsoft.AspNet.Server.Kestrel.Https": "1.0.0-*", + "Microsoft.AspNet.Testing": "1.0.0-*", + "System.Net.Http": "4.0.1-beta-*" }, "frameworks": { - "dnx451": { - "dependencies": { - "System.Net.Http": "4.0.1-beta-*", - "Microsoft.AspNet.Server.Kestrel.Https": "1.0.0-*" - } - }, + "dnx451": { }, "dnxcore50": { "dependencies": { "System.Diagnostics.TraceSource": "4.0.0-beta-*", "System.IO": "4.0.11-beta-*", + "System.Net.Http.WinHttpHandler": "4.0.0-beta-*", "System.Net.Sockets": "4.1.0-beta-*", "System.Runtime.Handles": "4.0.1-beta-*" }