Skip to content

Commit 8fc8307

Browse files
committed
Embed private key with the test X.509 certificate
- Use the PKCS #12 certificate format to enable this
1 parent 0844369 commit 8fc8307

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

samples/SampleApp/Startup.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Microsoft.AspNet.Builder;
66
using Microsoft.AspNet.Http;
77
using Microsoft.Extensions.Logging;
8+
using Microsoft.Dnx.Runtime;
89

910
#if DNX451
1011
using System.IO;
@@ -16,20 +17,20 @@ namespace SampleApp
1617
{
1718
public class Startup
1819
{
19-
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
20+
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IApplicationEnvironment env)
2021
{
2122
loggerFactory.MinimumLevel = LogLevel.Debug;
2223

2324
loggerFactory.AddConsole(LogLevel.Debug);
2425

2526
#if DNX451
2627
var testCertPath = Path.Combine(
27-
Environment.CurrentDirectory,
28-
@"../../test/Microsoft.AspNet.Server.KestrelTests/TestResources/testCert.cer");
28+
env.ApplicationBasePath,
29+
@"../../test/Microsoft.AspNet.Server.KestrelTests/TestResources/testCert.pfx");
2930

3031
if (File.Exists(testCertPath))
3132
{
32-
app.UseKestrelHttps(new X509Certificate2(testCertPath));
33+
app.UseKestrelHttps(new X509Certificate2(testCertPath, "testPassword"));
3334
}
3435
else
3536
{

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ public async Task CanReadAndWriteWithHttpsConnectionFilter()
4949
var sereverAddress = "https://localhost:54321/";
5050
var serviceContext = new TestServiceContext()
5151
{
52-
ConnectionFilter = new HttpsConnectionFilter(new X509Certificate2(@"TestResources/testCert.cer"), new NoOpConnectionFilter())
52+
ConnectionFilter = new HttpsConnectionFilter(
53+
new X509Certificate2(@"TestResources/testCert.pfx", "testPassword"),
54+
new NoOpConnectionFilter())
5355
};
5456

5557
using (var server = new TestServer(App, serviceContext, sereverAddress))
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)