React to UseHttps change
This commit is contained in:
parent
7eabf5cf3a
commit
eb24a9761a
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
|
|
@ -23,12 +24,35 @@ namespace AutobahnTestApp
|
||||||
{
|
{
|
||||||
builder.UseHttpSys();
|
builder.UseHttpSys();
|
||||||
}
|
}
|
||||||
|
else if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT")))
|
||||||
|
{
|
||||||
|
// ANCM is hosting the process.
|
||||||
|
// The port will not yet be configure at this point, but will also not require HTTPS.
|
||||||
|
builder.UseKestrel();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Also check "server.urls" for back-compat.
|
||||||
|
var urls = builder.GetSetting(WebHostDefaults.ServerUrlsKey) ?? builder.GetSetting("server.urls");
|
||||||
|
builder.UseSetting(WebHostDefaults.ServerUrlsKey, string.Empty);
|
||||||
|
|
||||||
|
if (urls.Contains(";"))
|
||||||
|
{
|
||||||
|
throw new NotSupportedException("This test app does not support multiple endpoints.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var uri = new Uri(urls);
|
||||||
|
|
||||||
builder.UseKestrel(options =>
|
builder.UseKestrel(options =>
|
||||||
{
|
{
|
||||||
var certPath = Path.Combine(AppContext.BaseDirectory, "TestResources", "testCert.pfx");
|
options.Listen(IPAddress.Loopback, uri.Port, listenOptions =>
|
||||||
options.UseHttps(certPath, "testPassword");
|
{
|
||||||
|
if (uri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
var certPath = Path.Combine(AppContext.BaseDirectory, "TestResources", "testCert.pfx");
|
||||||
|
listenOptions.UseHttps(certPath, "testPassword");
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue