public static IWebHostBuilder CreateWebHostBuilder(string[] args){var dic= ReadConfig();return WebHost.CreateDefaultBuilder(args).UseKestrel(option = {option.Listen(System.Net.IPAddress.Any, Convert....
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
}
沃梦达教程
本文标题为:Linux中发布.netcore时启用ssl
基础教程推荐
猜你喜欢
- C# List实现行转列的通用方案 2022-11-02
- C# windows语音识别与朗读实例 2023-04-27
- linux – 如何在Debian Jessie中安装dotnet core sdk 2023-09-26
- unity实现动态排行榜 2023-04-27
- C#类和结构详解 2023-05-30
- ZooKeeper的安装及部署教程 2023-01-22
- C# 调用WebService的方法 2023-03-09
- 一个读写csv文件的C#类 2022-11-06
- C#控制台实现飞行棋小游戏 2023-04-22
- winform把Office转成PDF文件 2023-06-14