Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit 55f6f21

Browse files
committed
Build Microsoft.AspNet.Server.Kestrel.Https for dotnet5.4
1 parent bdbd9ae commit 55f6f21

File tree

5 files changed

+26
-23
lines changed

5 files changed

+26
-23
lines changed

samples/SampleApp/Startup.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5+
using System.IO;
6+
using System.Security.Cryptography.X509Certificates;
57
using Microsoft.AspNet.Builder;
68
using Microsoft.AspNet.Http;
79
using Microsoft.AspNet.Http.Features;
810
using Microsoft.AspNet.Server.Kestrel;
9-
using Microsoft.Extensions.PlatformAbstractions;
10-
using Microsoft.Extensions.Logging;
11-
12-
#if DNX451
13-
using System.IO;
14-
using System.Security.Cryptography.X509Certificates;
1511
using Microsoft.AspNet.Server.Kestrel.Https;
16-
#endif
12+
using Microsoft.Extensions.Logging;
13+
using Microsoft.Extensions.PlatformAbstractions;
1714

1815
namespace SampleApp
1916
{
@@ -29,7 +26,6 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IAp
2926

3027
loggerFactory.AddConsole(LogLevel.Debug);
3128

32-
#if DNX451
3329
var testCertPath = Path.Combine(
3430
env.ApplicationBasePath,
3531
@"../../test/Microsoft.AspNet.Server.KestrelTests/TestResources/testCert.pfx");
@@ -42,7 +38,6 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IAp
4238
{
4339
Console.WriteLine("Could not find certificate at '{0}'. HTTPS is not enabled.", testCertPath);
4440
}
45-
#endif
4641

4742
app.Run(async context =>
4843
{

samples/SampleApp/project.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
"version": "1.0.0-*",
33
"dependencies": {
44
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
5+
"Microsoft.AspNet.Server.Kestrel.Https": "1.0.0-*",
56
"Microsoft.Extensions.Logging.Console": "1.0.0-*"
67
},
78
"frameworks": {
89
"dnx451": {
9-
"dependencies": {
10-
"Microsoft.AspNet.Server.Kestrel.Https": "1.0.0-*"
11-
}
1210
},
1311
"dnxcore50": {
1412
"dependencies": {

src/Microsoft.AspNet.Server.Kestrel.Https/project.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*"
1313
},
1414
"frameworks": {
15-
"net451": { }
15+
"net451": { },
16+
"dotnet5.4": {
17+
"dependencies": {
18+
"System.Net.Security": "4.0.0-beta-*"
19+
}
20+
}
1621
}
1722
}

test/Microsoft.AspNet.Server.KestrelTests/HttpsConnectionFilterTests.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
#if DNX451
4+
using System;
55
using System.Collections.Generic;
66
using System.Net;
77
using System.Net.Http;
@@ -47,7 +47,13 @@ public async Task CanReadAndWriteWithHttpsConnectionFilter()
4747

4848
try
4949
{
50+
#if DNX451
51+
var handler = new HttpClientHandler();
5052
ServicePointManager.ServerCertificateValidationCallback += validationCallback;
53+
#else
54+
var handler = new WinHttpHandler();
55+
handler.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
56+
#endif
5157

5258
var sereverAddress = "https://localhost:54321/";
5359
var serviceContext = new TestServiceContext()
@@ -59,7 +65,7 @@ public async Task CanReadAndWriteWithHttpsConnectionFilter()
5965

6066
using (var server = new TestServer(App, serviceContext, sereverAddress))
6167
{
62-
using (var client = new HttpClient())
68+
using (var client = new HttpClient(handler))
6369
{
6470
var result = await client.PostAsync(sereverAddress, new FormUrlEncodedContent(new[] {
6571
new KeyValuePair<string, string>("content", "Hello World?")
@@ -71,9 +77,10 @@ public async Task CanReadAndWriteWithHttpsConnectionFilter()
7177
}
7278
finally
7379
{
80+
#if DNX451
7481
ServicePointManager.ServerCertificateValidationCallback -= validationCallback;
82+
#endif
7583
}
7684
}
7785
}
7886
}
79-
#endif

test/Microsoft.AspNet.Server.KestrelTests/project.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,17 @@
33
"dependencies": {
44
"xunit.runner.aspnet": "2.0.0-aspnet-*",
55
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
6-
"Microsoft.AspNet.Testing": "1.0.0-*"
6+
"Microsoft.AspNet.Server.Kestrel.Https": "1.0.0-*",
7+
"Microsoft.AspNet.Testing": "1.0.0-*",
8+
"System.Net.Http": "4.0.1-beta-*"
79
},
810
"frameworks": {
9-
"dnx451": {
10-
"dependencies": {
11-
"System.Net.Http": "4.0.1-beta-*",
12-
"Microsoft.AspNet.Server.Kestrel.Https": "1.0.0-*"
13-
}
14-
},
11+
"dnx451": { },
1512
"dnxcore50": {
1613
"dependencies": {
1714
"System.Diagnostics.TraceSource": "4.0.0-beta-*",
1815
"System.IO": "4.0.11-beta-*",
16+
"System.Net.Http.WinHttpHandler": "4.0.0-beta-*",
1917
"System.Net.Sockets": "4.1.0-beta-*",
2018
"System.Runtime.Handles": "4.0.1-beta-*"
2119
}

0 commit comments

Comments
 (0)