Kestrel - 使用我的机器上已有的特定 SSL 证书
Optimizely CMS(艺术家以前称为EPiServer)最近发布了.Net Core版本。我可以使用 Kestrel 运行我的网站。但是,我想为我的网站设置一个特定的 url,并且我想为此 url 使用现有的 SSL 证书。
该证书安装在我的计算机上的 WebHosting 商店中。
这是我的 Kestrel 配置:
launchSettings.json
"MySampleProject": {
"commandName": "Project",
"launchBrowser": true,
"externalUrlConfiguration": true,
"applicationUrl": "https://sampleproject.local.hostname.dev",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
appsettings.json
"Kestrel": {
"Endpoints": {
"HttpsInlineCertStore": {
"Url": "https://sampleproject.local.hostname.dev",
"Certificate": {
"Subject": "local.hostname.dev",
"Store": "WebHosting",
"Location": "LocalMachine",
"AllowInvalid": "true"
}
}
}
在 program.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);
});
}
我认为配置存在一些问题?但我很难找到有关如何执行此操作的文档。
Optimizely CMS (the artist formerly known as EPiServer) recently released a .Net Core version. I can run my site using Kestrel. But, I want to set a specific url for my site, and I want to use an already existing SSL cert for this url.
The cert is installed on my machine in the WebHosting store.
Here is my Kestrel config:
launchSettings.json
"MySampleProject": {
"commandName": "Project",
"launchBrowser": true,
"externalUrlConfiguration": true,
"applicationUrl": "https://sampleproject.local.hostname.dev",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
appsettings.json
"Kestrel": {
"Endpoints": {
"HttpsInlineCertStore": {
"Url": "https://sampleproject.local.hostname.dev",
"Certificate": {
"Subject": "local.hostname.dev",
"Store": "WebHosting",
"Location": "LocalMachine",
"AllowInvalid": "true"
}
}
}
In program.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);
});
}
I assume there is some issue with the config? But I am having a hard time finding documentation around how to do this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
宾果游戏。找到了所需的方法来做到这一点。
这是appsettings
然后是Program.cs
Bingo. Found the desired way to do it.
Here is the appsettings
And then in Program.cs
这是“一个”解决方案。我不认为这是最好的解决方案,但它确实有效。
这是我的 Kestrel 应用程序设置:
}
然后在我的 Program.cs 中,
关键是如何指向不在默认证书存储中的证书。我管理多个网站,我的证书位于该网络托管商店中。有一个带有商店名称的枚举,但虚拟主机不是该枚举的一部分。而且,我希望它在配置中,而不是代码中,因此不同的开发人员可以有不同的设置。
我想让它只使用应用程序设置中的内容,我只需调用 UseKestral() 或其他内容并从配置中读取。但这至少有效。
This is "a" solution. I dont think its the best solution, but it works.
Here is my appsettings for Kestrel:
}
Then in my Program.cs
The keys thing was how do I point to a cert that wasnt in the default cert store. I manage several sites, and my cert is in that webhosting store. There is an Enum with store names, but webhosting isnt part of that enum. AND, I wanted it in config, not code, so a different developer could have a different set up.
I would like to make it so that it just uses whats in the appsettings and I just call UseKestral() or something and reads from the config. But this at least works.