我对 DefaultCredentials 选项和 HTTPS 有疑问。如果我使用 HTTP 协议,一切正常 - ntlm 授权正常,但如果我在 Thread.CurrentPrincipal 的 web 服务端将 HTTP 更改为 HTTPS,我什么都没有(空字符串和 IsAuthenticate 为 false 值)。你有类似的问题吗?
我的 Ntlm 配置:
internal class NtlmSelfHostConfiguration : HttpSelfHostConfiguration
{
public NtlmSelfHostConfiguration(string baseAddress) : base(baseAddress) { }
public NtlmSelfHostConfiguration(Uri baseAddress) : base(baseAddress) { }
protected override BindingParameterCollection OnConfigureBinding(HttpBinding httpBinding)
{
httpBinding.Security.Mode = HttpBindingSecurityMode.Transport;
httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
return base.OnConfigureBinding(httpBinding);
}
}
HttpClient 创建
var handler = new HttpClientHandler() { UseDefaultCredentials = true };
httpClient = new HttpClient(handler);
用户密码基本身份验证工作正常,因此证书没有问题