// using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.AspNetCore.Server.Kestrel.Https; using System.Net.Security; using System.Security.Cryptography.X509Certificates; var builder = WebApplication.CreateBuilder(args); builder.WebHost.ConfigureKestrel(options => { options.ListenAnyIP(8080, listenOptions => { listenOptions.Protocols = HttpProtocols.Http1AndHttp2AndHttp3; listenOptions.UseHttps(new TlsHandshakeCallbackOptions { OnConnection = context => { var options = new SslServerAuthenticationOptions { ServerCertificate = MyResolveCertForHost(context.ClientHelloInfo.ServerName) }; return new ValueTask(options); }, }); }); }); // var app = builder.Build(); app.MapGet("/", () => "Hello World!"); app.Run(); X509Certificate MyResolveCertForHost(string serverName) { throw new NotImplementedException(); }