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#实现http不同方法的请求 2022-12-26
- c# – USING块在网站与Windows窗体中的行为不同 2023-09-20
- Unity shader实现高斯模糊效果 2023-01-16
- Unity 如何获取鼠标停留位置下的物体 2023-04-10
- C#中 Json 序列化去掉null值的方法 2022-11-18
- C# 解析XML和反序列化的示例 2023-04-14
- C#调用摄像头实现拍照功能的示例代码 2023-03-09
- C#获取指定目录下某种格式文件集并备份到指定文件夹 2023-05-30
- C#中的Linq to JSON操作详解 2023-06-08
- C#通过标签软件Bartender的ZPL命令打印条码 2023-05-16
