通过openssl生成证书
openssl req -newkey rsa:2048 -nodes -keyout my.key -x509 -days 365 -out my.cer openssl pkcs12 -export -in my.cer -inkey my.key -out my.pfx
将pfx设置为Embedded resource
program 添加代码
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseKestrel(opt => opt.ConfigureHttpsDefaults(x => x.ServerCertificate = Certificate.Get())); webBuilder.UseStartup<Startup>(); });
源码:
https://github.com/wswind/Support-SSL-Sample.git
参考:
https://www.cnblogs.com/edisonchou/p/identityserver4_foundation_and_quickstart_01.html
https://www.cnblogs.com/linezero/p/aspnetcorehttps.html
https://github.com/dotnet-architecture/eShopOnContainers