- 准备证书 (购买 或 自己生成)
假设为 localhost.pfx,保存到某个目录。
假设密码为 password。
- 添加依赖引用(project.json)
"Microsoft.AspNet.Server.Kestrel.Https": ****
- 添加侦听端口(project.json)
"web": "Microsoft.AspNet.Server.Kestrel --server.urls=http://*:8000;https://*:44300"
- 加载证书 (startup.cs)
// Configure
var sslCert = new "Certs/localhost.pfx"), "password");
app.UseKestrelHttps( sslCert);