public static IWebHostBuilder CreateWebHostBuilder(string[] args){var dic= ReadConfig();return WebHost.CreateDefaultBuilder(args).UseKestrel(option = {option.Listen(System.Net.IPAddress.Any, Convert....
![](https://oss.womengda.net/imgfile/2309/1E413412543G0-21WP.jpg)
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
![](/xwassets/images/pre.png)
![](/xwassets/images/next.png)
猜你喜欢
- .NET CORE DI 依赖注入 2023-09-27
- 在C# 8中如何使用默认接口方法详解 2023-03-29
- c# 模拟线性回归的示例 2023-03-14
- Unity3D实现渐变颜色效果 2023-01-16
- 如何使用C# 捕获进程输出 2023-03-10
- WPF使用DrawingContext实现绘制刻度条 2023-07-04
- Oracle中for循环的使用方法 2023-07-04
- user32.dll 函数说明小结 2022-12-26
- C# 使用Aspose.Cells 导出Excel的步骤及问题记录 2023-05-16
- Unity Shader实现模糊效果 2023-04-27