一佳一

记录像1+1一样简洁的代码

导航

.NET5 本地境配置https 无需搭建SSL环境

Posted on 2021-05-22 18:14  一佳一  阅读(780)  评论(0编辑  收藏  举报

1.修改用Kestrel

 .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseUrls("http://*:5000", "https://*:5001").UseStartup<Startup>();
                    webBuilder.UseKestrel(option =>
                    {
                        option.ConfigureHttpsDefaults(o =>
                        {
                            o.ServerCertificate =
                                new System.Security.Cryptography.X509Certificates.X509Certificate2(@"E:\charger\ssl\Certificate.pfx", "F3ibzYy2"); //证书路径、密码
                        });
                    });
                })

2.用工具CreateCertGU生成crt证书

下载地址 https://download.csdn.net/download/jine515073/18972476

 

 3.转换成pfx  地址:https://www.ssldun.com/tools/ssl-converter.php

 

 4.双击安装证书到信任位置