1

From the project properties we could do it as follows for IIS Express enter image description here

but I am using the console for a IdentityServer4 Identity provider host. enter image description here so I must configure it from Program.cs or Startup.cs since I have no such options on project properties when using console. enter image description here

3
  • 1
    AFAIK: Windows authentication is provided by IIS. You remove IIS you remove Windows Authentication. Kestrel is not intended to be hosted without a reverse proxy like IIS or nginx Commented Apr 17, 2018 at 13:52
  • Yes. I had read documentation about Kestrel vs HTTP.sys and I had found very useful that answer: stackoverflow.com/questions/46621788/… Commented Apr 19, 2018 at 16:49
  • I hope you read the "IMPORTANT NOTE" over and over again. While your scenario is supported, it's a very bad idea Commented Apr 19, 2018 at 16:52

2 Answers 2

1

IIS and Windows authentication is not applicable when you host your service with the console app. I am using the below code enable HTTPS for my identity server

public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseKestrel(options => 
                {
                    options.Listen(IPAddress.Any,44333, listenOptions =>
                    {
                      listenOptions.UseHttps("Path to SSL certificate","SSL Cert Password");
                        }

                    });
                })
                .UseStartup<Startup>()
                .Build();
Sign up to request clarification or add additional context in comments.

Comments

1

I see you are using .NET Core.

.NET Core is hosted in Kestrel instead of the normal IIS and does not support windows authentication. Although you can use HTTP.sys which is a web server implementation in .NET Core and does support windows authentication.

The below code configures the app's web host to use HTTP.sys with Windows authentication.

public class Program
{
    public static void Main(string[] args) => 
        BuildWebHost(args).Run();

    public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>()
            .UseHttpSys(options =>
            {
                options.Authentication.Schemes = 
                    AuthenticationSchemes.NTLM | AuthenticationSchemes.Negotiate;
                options.Authentication.AllowAnonymous = false;
            })
            .Build();
}

the article explaining this code is here

3 Comments

".NET Core is hosted in Kestrel instead of the normal IIS and does not support windows authentication" this is completely wrong. Kestrel supports IIS and it's the default integration in new projects
Since HTTP.sys only works on windows and I will porting to docker the application behind a web server proxy. I will continue using Kestrel. Thanks anyway for your reply
@Camilo Terevinto please check here for more information on Kestrel: Kestrel web server. > Kestrel is a cross-platform web server for ASP.NET Core based on libuv, a cross-platform asynchronous I/O library. Kestrel is the web server that's included by default in ASP.NET Core project templates. Kestrel is the web server .NET Core is hosted in. IIS is one of many possiblities to use as a reverse proxy to get the traffic to the Kestrel web server. -edit for user tagging

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.