Eth*_*fer 5 ssl-certificate kestrel
Optimizely CMS(艺术家以前称为EPiServer)最近发布了.Net Core版本。我可以使用 Kestrel 运行我的网站。但是,我想为我的网站设置一个特定的 url,并且我想为此 url 使用现有的 SSL 证书。
该证书安装在我的计算机上的 WebHosting 商店中。
这是我的 Kestrel 配置:
启动设置.json
"MySampleProject": {
"commandName": "Project",
"launchBrowser": true,
"externalUrlConfiguration": true,
"applicationUrl": "https://sampleproject.local.hostname.dev",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
Run Code Online (Sandbox Code Playgroud)
应用程序设置.json
"Kestrel": {
"Endpoints": {
"HttpsInlineCertStore": {
"Url": "https://sampleproject.local.hostname.dev",
"Certificate": {
"Subject": "local.hostname.dev",
"Store": "WebHosting",
"Location": "LocalMachine",
"AllowInvalid": "true"
}
}
}
Run Code Online (Sandbox Code Playgroud)
在程序.cs中
public static IHostBuilder CreateHostBuilder(string[] args, bool isDevelopment)
{
return Host.CreateDefaultBuilder(args)
.ConfigureCmsDefaults()
.UseSerilog()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureKestrel(serverOptions => serverOptions.AddServerHeader = false);
webBuilder.UseStartup<Startup>();
})
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.SetMinimumLevel(LogLevel.Trace);
});
}
Run Code Online (Sandbox Code Playgroud)
我认为配置有问题?但我很难找到有关如何执行此操作的文档。
答对了。找到了所需的方法来做到这一点。
这是应用程序设置
"Kestrel": {
"Endpoints": {
"Https": {
"Url": "https://sampleproject.local.hostname.dev:8001",
"Certificate": {
"Subject": "local.hostname.dev",
"Store": "webhosting",
"Location": "LocalMachine"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后在Program.js中
return Host.CreateDefaultBuilder(args)
.ConfigureCmsDefaults()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseKestrel();
webBuilder.UseStartup<Startup>();
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5142 次 |
| 最近记录: |