zoukankan      html  css  js  c++  java
  • Linux中发布.netcore时启用ssl

     public static IWebHostBuilder CreateWebHostBuilder(string[] args)
            {
               var dic= ReadConfig();
                return WebHost.CreateDefaultBuilder(args)
                     .UseKestrel(option => {
                         option.Listen(System.Net.IPAddress.Any, Convert.ToInt32(dic["server_port"]), (lop) => {
                             lop.UseHttps(dic["pfx_name"], dic["pfx_pswd"]);
                         });
                     })
                    //.UseConfiguration(new ConfigurationBuilder().AddJsonFile("config.json", true).Build())
                    .UseStartup<Startup1>()
                    .ConfigureLogging((hostingContext, logging) =>
                    {
                        logging.ClearProviders();
                        logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
                        //暂时不根据dev还是product环境来屏蔽日志的console或者文件
                        logging.AddConsole();
                        //logging.AddDebug(); //output窗口
                    })
                    .UseNLog();
            }
     private static Dictionary<string, string> ReadConfig()
            {
                try
                {
                    using (FileStream fs = new FileStream("config.json", FileMode.Open))
                    {
                        using (StreamReader sr = new StreamReader(fs))
                        {
                            return JsonConvert.DeserializeObject<Dictionary<string, string>>(sr.ReadToEnd());
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
    
    
            }
    config.json:

    {
    "pfx_name": "server_keystore.pfx",
    "pfx_pswd": "87654321",
    "server_port": 443
    }

  • 相关阅读:
    leetcode 443: String Compression,357: Count Numbers with Unique Digits
    C++ 中 freopen()函数的用法
    filter
    map
    os.listdir
    os.path.join
    assert
    numpy中的axis和Pytorch中的dim参数
    mac中qq接收视频存放的位置
    requests
  • 原文地址:https://www.cnblogs.com/hepeng/p/12162457.html
Copyright © 2011-2022 走看看