小编Bar*_*rez的帖子

如何修复“发生一个或多个错误。(无法建立 SSL 连接,请参阅内部异常。)'?

我创建了 web api,当尝试添加 ssl 时出现此错误,当代码尝试到达 web api 中的端点时,我收到此错误,这是一个自签名证书。

这是开发环境,使用 Visual Studio 2019 调试代码,但在尝试重新创建 ssl 证书后没有运气,检查了有关在 .net 核心应用程序中实现 https 的指南,但没有运气。

程序.cs:

 public static void Main(string[] args)
        {
            CreateWebHostBuilder(args).Build().Run();
        }

        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseUrls("http://*:5000")
                .UseSetting("https_port", "5001")
                .UseKestrel(options =>
                {

                    options.Listen(System.Net.IPAddress.Any, 5000);
                    options.Listen(System.Net.IPAddress.Any, 5001,
                        listenOptions => { listenOptions.UseHttps("localhost.pfx", "A2345_678b"); });
                })
                .UseStartup<Startup>();
    }
Run Code Online (Sandbox Code Playgroud)

Startup.cs 中的配置服务:

services.AddSignalR();
            services.AddMvc(options => options.EnableEndpointRouting = false).SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });
            services.AddDefaultIdentity<IdentityUser>().AddRoles<IdentityRole>()
            .AddEntityFrameworkStores<SmartContext>();

             services.AddMvc(
                     options =>
                     {
                         options.SslPort = 5001;
                         options.Filters.Add(new RequireHttpsAttribute()); …
Run Code Online (Sandbox Code Playgroud)

c# ssl https asp.net-core-webapi

0
推荐指数
1
解决办法
7116
查看次数

标签 统计

asp.net-core-webapi ×1

c# ×1

https ×1

ssl ×1