为.net mvc core 启用 https

        public static IHostBuilder CreateHostBuilder(string[] args)
        {
            var x509ca = new X509Certificate2("./ServerCert.pfx", "password");

            return Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseKestrel(option => option.ConfigureEndpointDefaults(c=>c.UseHttps(x509ca)));
                    webBuilder.UseStartup<Startup>();
                });
        }

appsetings.json内容:

{
  "urls": "http://*:6000",

  "Serilog": {
    "MinimumLevel": {
      "Default": "Verbose",
      "Override": {
        "System": "Warning",
        "Microsoft": "Warning"
      }
    }
  }
}

 

posted @ 2017-10-17 16:20  IWing  阅读(2525)  评论(0编辑  收藏  举报