编程语言
首页 > 编程语言> > 部署asp.net core支持https 使用openssl自签ssl证书

部署asp.net core支持https 使用openssl自签ssl证书

作者:互联网

通过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

标签:core,自签,asp,com,openssl,html,https,webBuilder,my
来源: https://www.cnblogs.com/wswind/p/11847345.html