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.
Bingo. Found the desired way to do it.
Here is the appsettings
"Kestrel": {
"Endpoints": {
"Https": {
"Url": "https://sampleproject.local.hostname.dev:8001",
"Certificate": {
"Subject": "local.hostname.dev",
"Store": "webhosting",
"Location": "LocalMachine"
}
}
}
}
And then in Program.cs
return Host.CreateDefaultBuilder(args)
.ConfigureCmsDefaults()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseKestrel();
webBuilder.UseStartup<Startup>();
});