目的: 使用.netcore自带的kestrel加载自己指定的ssl 实验版本
- aspnet core 2.2
- aspnet core 3.1
首先准备ssl文件:(密码为:123456) 代码如下: - using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore;
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.Logging;
- namespace server
- {
- public class Program
- {
- public static void Main(string[] args)
- {
- CreateWebHostBuilder(args).Build().Run();
- }
- public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
- WebHost.CreateDefaultBuilder(args)
- .UseUrls("https://*:5001")
- .UseKestrel(option =>
- {
- option.ConfigureHttpsDefaults(i =>
- {
- i.ServerCertificate = new System.Security.Cryptography.X509Certificates.X509Certificate2("./ssl.pfx", "123456");
- });
- }).UseStartup<Startup>();
- }
- }
复制代码 来源:https://blog.csdn.net/u010476739/article/details/103337633 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |