Where can I find some documentation regarding which options are available on the hosting.json
file? Right now I'm using the server.ulrs
but I'm wondering if I can add the https certificate path/password on it.
My hosting.json
:
{
"server.urls": "http://0.0.0.0:80;https://0.0.0.0:443"
}
Where I'm using it:
public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("hosting.json", optional: true) // <<<<<<<<< LOADING FILE
.Build();
var host = new WebHostBuilder()
.UseKestrel()
.UseConfiguration(config) // <<<<<<<<<<< USING IT
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
Short Answer
Out of the box, you cannot use hosting.json to set up your HTTPs certificate and credentials. You can, though, write custom code to support that scenario. There is a GitHub issue about that with a sample project by the Tratcher.
The hosting.json file usually passes its options to the
WebHostBuilder.UseConfiguration
method.This is that static class:
Example
For instance, the following hosting.json file...
...and the following entry point...
...leads to the following output...
Remarks
urls
instead ofserver.urls
. The latter is listed as theDeprecatedServerUrlsKey
in the GitHub.com/aspnet/hosting repository.