2020-03-24 19:08:37 +01:00
|
|
|
// Copyright (c) Microsoft Corporation.
|
2018-02-13 18:23:53 +01:00
|
|
|
// Licensed under the MIT License.
|
2020-09-02 05:15:16 +02:00
|
|
|
|
2018-02-13 18:23:53 +01:00
|
|
|
using System;
|
2017-08-31 11:30:35 +02:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Net;
|
|
|
|
using System.Security.Authentication;
|
|
|
|
using System.Security.Cryptography.X509Certificates;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Microsoft.AspNetCore;
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
using Microsoft.AspNetCore.Server.Kestrel.Https;
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
namespace mvc
|
|
|
|
{
|
|
|
|
public class Program
|
|
|
|
{
|
|
|
|
public static void Main(string[] args)
|
|
|
|
{
|
2020-11-11 07:55:39 +01:00
|
|
|
if (args.Length != 7)
|
2017-08-31 11:30:35 +02:00
|
|
|
{
|
2020-09-02 19:18:15 +02:00
|
|
|
System.Console.WriteLine("Required: <CertificatePath> <CertificatePassword> <HTTPPortNumber> <HTTPSPortNumberTls12> <HTTPSPortNumberTls11> <HTTPSPortNumberTls> <HTTPSPortNumberTls12>");
|
2019-05-21 07:43:51 +02:00
|
|
|
Environment.Exit(1);
|
2017-08-31 11:30:35 +02:00
|
|
|
}
|
2018-12-24 07:20:06 +01:00
|
|
|
|
2017-08-31 11:30:35 +02:00
|
|
|
BuildWebHost(args).Run();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static IWebHost BuildWebHost(string[] args) =>
|
|
|
|
WebHost.CreateDefaultBuilder()
|
|
|
|
.UseStartup<Startup>().UseKestrel(options =>
|
|
|
|
{
|
2019-05-21 07:43:51 +02:00
|
|
|
options.AllowSynchronousIO = true;
|
2017-08-31 11:30:35 +02:00
|
|
|
options.Listen(IPAddress.Loopback, int.Parse(args[2]));
|
|
|
|
options.Listen(IPAddress.Loopback, int.Parse(args[3]), listenOptions =>
|
|
|
|
{
|
|
|
|
var certificate = new X509Certificate2(args[0], args[1]);
|
|
|
|
HttpsConnectionAdapterOptions httpsOption = new HttpsConnectionAdapterOptions();
|
|
|
|
httpsOption.SslProtocols = SslProtocols.Tls12;
|
|
|
|
httpsOption.ClientCertificateMode = ClientCertificateMode.AllowCertificate;
|
2020-11-21 15:30:59 +01:00
|
|
|
httpsOption.ClientCertificateValidation = (inCertificate, inChain, inPolicy) => { return true; };
|
2017-08-31 11:30:35 +02:00
|
|
|
httpsOption.CheckCertificateRevocation = false;
|
|
|
|
httpsOption.ServerCertificate = certificate;
|
|
|
|
listenOptions.UseHttps(httpsOption);
|
|
|
|
});
|
2017-11-13 19:45:46 +01:00
|
|
|
options.Listen(IPAddress.Loopback, int.Parse(args[4]), listenOptions =>
|
|
|
|
{
|
|
|
|
var certificate = new X509Certificate2(args[0], args[1]);
|
|
|
|
HttpsConnectionAdapterOptions httpsOption = new HttpsConnectionAdapterOptions();
|
|
|
|
httpsOption.SslProtocols = SslProtocols.Tls11;
|
|
|
|
httpsOption.ClientCertificateMode = ClientCertificateMode.AllowCertificate;
|
2020-11-21 15:30:59 +01:00
|
|
|
httpsOption.ClientCertificateValidation = (inCertificate, inChain, inPolicy) => { return true; };
|
2017-11-13 19:45:46 +01:00
|
|
|
httpsOption.CheckCertificateRevocation = false;
|
|
|
|
httpsOption.ServerCertificate = certificate;
|
|
|
|
listenOptions.UseHttps(httpsOption);
|
|
|
|
});
|
|
|
|
options.Listen(IPAddress.Loopback, int.Parse(args[5]), listenOptions =>
|
|
|
|
{
|
|
|
|
var certificate = new X509Certificate2(args[0], args[1]);
|
|
|
|
HttpsConnectionAdapterOptions httpsOption = new HttpsConnectionAdapterOptions();
|
|
|
|
httpsOption.SslProtocols = SslProtocols.Tls;
|
|
|
|
httpsOption.ClientCertificateMode = ClientCertificateMode.AllowCertificate;
|
2020-11-21 15:30:59 +01:00
|
|
|
httpsOption.ClientCertificateValidation = (inCertificate, inChain, inPolicy) => { return true; };
|
2017-11-13 19:45:46 +01:00
|
|
|
httpsOption.CheckCertificateRevocation = false;
|
|
|
|
httpsOption.ServerCertificate = certificate;
|
|
|
|
listenOptions.UseHttps(httpsOption);
|
|
|
|
});
|
2020-09-02 19:18:15 +02:00
|
|
|
options.Listen(IPAddress.Loopback, int.Parse(args[6]), listenOptions =>
|
|
|
|
{
|
|
|
|
var certificate = new X509Certificate2(args[0], args[1]);
|
|
|
|
HttpsConnectionAdapterOptions httpsOption = new HttpsConnectionAdapterOptions();
|
|
|
|
httpsOption.SslProtocols = SslProtocols.Tls13;
|
|
|
|
httpsOption.ClientCertificateMode = ClientCertificateMode.AllowCertificate;
|
2020-11-21 15:30:59 +01:00
|
|
|
httpsOption.ClientCertificateValidation = (inCertificate, inChain, inPolicy) => { return true; };
|
2020-09-02 19:18:15 +02:00
|
|
|
httpsOption.CheckCertificateRevocation = false;
|
|
|
|
httpsOption.ServerCertificate = certificate;
|
|
|
|
listenOptions.UseHttps(httpsOption);
|
|
|
|
});
|
2017-08-31 11:30:35 +02:00
|
|
|
})
|
|
|
|
.Build();
|
|
|
|
}
|
|
|
|
}
|