ASP.NET Core的HTTP.sys Web服务器实现确实支持SNI。在ASP.NET Core的启动代码中,可以通过以下方式启用SNI支持:
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup()
.UseHttpSys(options =>
{
options.Authentication.Schemes = AuthenticationSchemes.None;
options.MaxConnections = null;
options.MaxRequestBodySize = 30000000;
options.UrlPrefixes.Add("https://localhost:44391");
options.UseConnectionLogging();
options.EnableResponseCaching();
options.Ssl.SslProtocols = SslProtocols.Tls12;
options.Ssl.ServerCertificate = LoadCertificate();
options.Ssl.ClientCertificateMode = ClientCertificateMode.NoCertificate;
})
在上面的代码段中,我们可以看到options.Ssl.ServerCertificate属性指定SSL的证书。在此例中,我们使用了一个自定义的函数LoadCertificate(),该函数可以加载证书并将其设置为ServerCertificate属性。如果要使用多域证书,可以在options.Ssl.ServerCertificate属性中设置正确的证书。