[英]Self-hosted OWIN .NET 4.5 Web API 2 does not work with Windows authentication and https
I am trying to get Web API 2 to work with Windows authentication and SSL. 我正在尝试使Web API 2与Windows身份验证和SSL一起使用。 It looks like it can work with either one or the other, but when I enable both Windows authentication and SSL, I keep getting 401 responses from the server. 看起来它可以与任何一个一起使用,但是当我同时启用Windows身份验证和SSL时,我不断从服务器获得401响应。
This is how we enable Windows authentication: 这是我们启用Windows身份验证的方式:
HttpListener listener = (HttpListener)appBuilder.Properties["System.Net.HttpListener"];
listener.AuthenticationSchemes = AuthenticationSchemes.IntegratedWindowsAuthentication;
When running with just HTTP (no HTTPS), Windows authentication seems to work. 当仅使用HTTP(无HTTPS)运行时,Windows身份验证似乎可以工作。 I see 401 responses followed by a 200 response. 我看到401响应,然后是200响应。
I am also trying to get it to work with HTTPS on my local machine. 我还试图使其在本地计算机上与HTTPS一起使用。
I went through the following steps to enable HTTPS: 我通过以下步骤来启用HTTPS:
https://+:10001/
) 保留URL( https://+:10001/
) Starting the service: 启动服务:
var startOptions = new StartOptions();
startOptions.Urls.Add(baseUrl); // baseUrl is "https://+:10001/"
_webApplication = WebApp.Start<Startup>(startOptions);
If I disable Windows authentication (comment out the 2 lines with HttpListener
above), I can access the service using the HTTPS protocol. 如果禁用Windows身份验证(用上面的HttpListener
注释掉两行),则可以使用HTTPS协议访问该服务。 The browser recognizes the certificate. 浏览器可以识别证书。
When I enable Windows authentication, I keep getting 401 responses (in Fiddler I can see up to 6 401 responses for one request). 启用Windows身份验证后,我一直收到401个响应(在Fiddler中,一个请求最多可以看到6 401个响应)。 A browser keeps prompting me to log in, and fails after a number of attempts with a 401 code. 浏览器不断提示我登录,并且多次尝试输入401代码后失败。
I have been trying to find someone facing a similar problem. 我一直在寻找一个面临类似问题的人。 This post looked promising. 这篇文章看起来很有希望。 However, the author did not seem to have any issues with the .NET 4.5 version of OWIN. 但是,作者似乎对.NET 4.5版本的OWIN没有任何问题。
Could anyone please advise? 有人可以建议吗? Thank you! 谢谢!
Our problem was the authentication rather than SSL. 我们的问题是身份验证而不是SSL。
AuthenticationSchemes.Ntlm
helped 使用AuthenticationSchemes.Ntlm
帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.