I am following this tutorial to add Facebook authentication to my web app.
As part of the process I am trying to enable SSL on my project but everything I have found involves updating a setting in the Project Properties dialog in Visual Studio, which is unavailable to me through Visual Studio Code on my Mac. I've tried updating the values in launchSettings.json manually, but I haven't had any luck.
How do I update launchSettings.json (or other project files) in Visual Studio Code to enable SSL while debugging?
If you don't want to change your Program.cs file just for debugging in VS Code, you can also configure the urls in your launch.json. You need to specify the urls in the env property. As xneg said you'll need to set up a self-signed cert to do this.
You can configure the http url and the https (SSL) url
"configurations":[
{
...
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "http://localhost:5002;https://localhost:5003"
},
...
}
The documentation for Kestrel was helpful in figuring this out.
I made the following edits to launchSettings.json on windows and it did the trick. Currently this is the only way to do it in Visual Studio 2017 RC .
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:50183/",
"sslPort": 44318
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "https://localhost:44318",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"corePostgresIdentity": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:44318"
}
}
}
When you run your ASP.NET Core app in VS Code you run it with Kestrel not IIS. You need to setup Kestrel to enable SSL manualy like this (in Program.cs):
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseKestrel(options =>
{
options.Listen(IPAddress.Loopback, 5000, listenOptions =>
{
listenOptions.UseHttps("localhost.pfx", "yourPassword");
});
})
.UseUrls("https://localhost:5000")
.Build();
How to create a self-signed certificate is described in this great article.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With