netcore配置https协议
1、在program.cs文件中添加如下代码:
webBuilder.ConfigureKestrel(options => { var ip = IPAddress.Parse(AppSettings.app(new string[] { "https", "ip" })); int port = int.Parse(AppSettings.app(new string[] { "https", "port" })); string pfxPath = AppSettings.app(new string[] { "https", "pfxPath" }); string pfxPassword = AppSettings.app(new string[] { "https", "pfxPassword" }); options.Listen(ip, port, listenOptions => { listenOptions.Protocols = HttpProtocols.Http2; listenOptions.UseHttps(pfxPath, pfxPassword); }); });
2、appsetting.json配置如下:
"https": { "ip": "192.168.40.10", "port": "8080", "pfxPath": "C:/Users/admin/Downloads/SHA256withRSA_m.sythams.com(1).pfx", "pfxPassword": "" }
本文来自博客园,作者:zwbsoft,转载请注明原文链接:https://www.cnblogs.com/zwbsoft/p/15996282.html
电话微信:13514280351