1 Star 0 Fork 0

月渊/asp.net core https test

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Program.cs 1.62 KB
一键复制 编辑 原始数据 按行查看 历史
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Server.Kestrel.Https;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace https
{
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseKestrel(opt=>
{
opt.Listen(IPAddress.Any, 443, op =>
{
var ada = new HttpsConnectionAdapterOptions();
ada.ServerCertificate = new X509Certificate2("D:\\tmp\\localhost.pfx", "wshy89");
ada.CheckCertificateRevocation = true;
ada.ClientCertificateMode = ClientCertificateMode.RequireCertificate;
ada.ClientCertificateValidation=((certificate2, chain, arg3) =>
{
return true;
});
op.UseHttps(ada);
// op.UseHttps()
});
})
.UseStartup<Startup>()
// .UseUrls("https://*:443")
.Build();
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/yzpopulation/asp.net-core-https-test.git
git@gitee.com:yzpopulation/asp.net-core-https-test.git
yzpopulation
asp.net-core-https-test
asp.net core https test
master

搜索帮助